@@ -186,6 +186,7 @@ macro_rules! exclude_utilities {
186
186
/// otherwise generated.
187
187
/// This is 'greedy' in the sense that any functions/methods
188
188
/// which take or return such a type will _also_ be blocked.
189
+ /// See also [`opaque`].
189
190
///
190
191
/// A directive to be included inside
191
192
/// [include_cpp] - see [include_cpp] for general information.
@@ -194,6 +195,35 @@ macro_rules! block {
194
195
( $( $tt: tt) * ) => { $crate:: usage!{ $( $tt) * } } ;
195
196
}
196
197
198
+ /// Instruct `bindgen` to generate a type as an opaque type -
199
+ /// that is, without fields inside it. This should be used
200
+ /// only when there's a need to workaround some `bindgen`
201
+ /// issue where it's incorrectly generating the type.
202
+ /// See the [bindgen documentation](https://rust-lang.github.io/rust-bindgen/opaque.html)
203
+ /// for what exactly this means.
204
+ ///
205
+ /// At first glance, this might seem to have no effect for
206
+ /// types which are marked non-POD. However, it prevents
207
+ /// autocxx from inferring whether the type has implicit
208
+ /// constructors, and thus limits the options for even
209
+ /// allocating the type. This should therefore only be used
210
+ /// when trying to work around a bug.
211
+ ///
212
+ /// The types which are generated when you use this are
213
+ /// rather useless - it's hard to interact with them at all
214
+ /// from within the generated Rust. Worse still, if they're
215
+ /// included as members of any other type, those types are
216
+ /// "infected" and also become useless (in the sense that
217
+ /// we can't figure out what constructors those types might
218
+ /// have). Use with caution and only when really needed.
219
+ ///
220
+ /// A directive to be included inside
221
+ /// [include_cpp] - see [include_cpp] for general information.
222
+ #[ macro_export]
223
+ macro_rules! opaque {
224
+ ( $( $tt: tt) * ) => { $crate:: usage!{ $( $tt) * } } ;
225
+ }
226
+
197
227
/// Avoid generating implicit constructors for this type.
198
228
/// The rules for when to generate C++ implicit constructors
199
229
/// are complex, and if autocxx gets it wrong, you can block
0 commit comments