-
Notifications
You must be signed in to change notification settings - Fork 324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request] Handle if
+ cfg!
in const context
#1018
Comments
Its unclear to me how this would work with the macro expansion feature. I'm not using the expasion feature in none of my projects that uses cbindgen |
I currently have a working version for C/C++, but I have no idea how would be the equivalent for Cython to turn panics-> |
Is there an established workaround for this? Right now I'm tempted to just place a manual copy of the cfg tree into the |
I think the only workaround for this is to create a bunch of |
Since the addition of
if
in const context, the usage ofif
+cfg!
macro became a thing, since it reduces the need of replication of docs and definition.Currently, cbindgen ignores this kind of construction, but ideally, supporting that would make easier for maintaining C-exported constants that differ on targets.
Possible expected result:
In const context, an
if
must always have anelse
, so it is also common to have panicking macros, likepanic!
,unimplemented!
,todo!
andunreacheble!
in theelse
clause. That causes an compiler error with the panic message if it reaches the panic. I think this could generate an#error
directive with the message.Example
The text was updated successfully, but these errors were encountered: