You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a problem with a crate that provides a optional ffi api that cbindgen should generate headers for. The entire ffi api is optional in that crate as the provided functionality can be used directly as a pure rust dependency also.
This means that every export function (and struct) has this cfg feature above it.
#[cfg(feature = "ffi")]
Cbindgen is not really suited to handling this use case directly.
If I do nothing then it just does not generate the exports for any functions and the header is blank.
If I enable the feature in cbindgen.tomls parse.expand section
features = ["ffi"]
Then the generated header is correct but I get 100s of outputs
WARN: Missing [defines] entry for feature = "ffi" in cbindgen config.
This is concerning as it would drown out actual warnings that I do actually care about.
I would expect this warning to only occur once and there does not appear to be a way of telling cbindgen that this feature is always enabled in all situations where the header is used.
I have tried to example add
"feature = ffi" = ""
to the defines block.
This gets rid of the warning but the generated header is not quite correct.
It outputs stuff like this in the header:
In the current cbindgen (0.27.0) you can get around the issue by assigning a custom macro to the feature and always defining it in after_includes or header.
This generates a header that works but contains 3 more lines per definition than necessary. Not ideal.
Thank you for providing this info. I will use this as a work around.
I have a problem with a crate that provides a optional ffi api that cbindgen should generate headers for. The entire ffi api is optional in that crate as the provided functionality can be used directly as a pure rust dependency also.
This means that every export function (and struct) has this cfg feature above it.
#[cfg(feature = "ffi")]
Cbindgen is not really suited to handling this use case directly.
If I do nothing then it just does not generate the exports for any functions and the header is blank.
If I enable the feature in cbindgen.tomls parse.expand section
features = ["ffi"]
Then the generated header is correct but I get 100s of outputs
WARN: Missing
[defines]
entry forfeature = "ffi"
in cbindgen config.This is concerning as it would drown out actual warnings that I do actually care about.
I would expect this warning to only occur once and there does not appear to be a way of telling cbindgen that this feature is always enabled in all situations where the header is used.
I have tried to example add
"feature = ffi" = ""
to the defines block.
This gets rid of the warning but the generated header is not quite correct.
It outputs stuff like this in the header:
#if defined()
bool export_function_name_here();
#endif
I would like a way to get rid of this warning and not emit any #if defined() block in the header.
The text was updated successfully, but these errors were encountered: