diff --git a/examples/foundation_custom_class.rs b/examples/foundation_custom_class.rs index 22bef447b..30dee30bd 100644 --- a/examples/foundation_custom_class.rs +++ b/examples/foundation_custom_class.rs @@ -6,7 +6,15 @@ use objc::runtime::{Class, Object, Sel}; use objc::Message; use objc_foundation::{INSObject, NSObject}; -pub enum MYObject {} +/// In the future this should be an `extern type`, if that gets stabilized, +/// see [RFC-1861](https://rust-lang.github.io/rfcs/1861-extern-types.html). +#[repr(C)] +pub struct MYObject { + /// See the [Nomicon] for details on representing opaque structs. + /// + /// [Nomicon]: https://doc.rust-lang.org/nomicon/ffi.html#representing-opaque-structs + _priv: [u8; 0], +} impl MYObject { fn number(&self) -> u32 { diff --git a/objc_exception/src/lib.rs b/objc_exception/src/lib.rs index 80098a24f..df924e3b9 100644 --- a/objc_exception/src/lib.rs +++ b/objc_exception/src/lib.rs @@ -24,7 +24,18 @@ extern "C" { } /// An opaque type representing any Objective-C object thrown as an exception. -pub enum Exception {} +/// +/// In the future this will be an [`extern type`][rfc-1861], if that gets +/// stabilized. +/// +/// [rfc-1861]: https://rust-lang.github.io/rfcs/1861-extern-types.html +#[repr(C)] +pub struct Exception { + /// See the [Nomicon] for details on representing opaque structs. + /// + /// [Nomicon]: https://doc.rust-lang.org/nomicon/ffi.html#representing-opaque-structs + _priv: [u8; 0], +} /// Throws an Objective-C exception. /// The argument must be a pointer to an Objective-C object. diff --git a/objc_foundation/src/macros.rs b/objc_foundation/src/macros.rs index 9b45930af..4c2e39a5d 100644 --- a/objc_foundation/src/macros.rs +++ b/objc_foundation/src/macros.rs @@ -1,8 +1,10 @@ #[macro_export] macro_rules! object_struct { ($name:ident) => { + // TODO: `extern type` + #[repr(C)] pub struct $name { - _private: (), + _private: [u8; 0], } unsafe impl ::objc::Message for $name {}