Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upFunctional C macros are not expanded. #753
Comments
This comment has been minimized.
This comment has been minimized.
|
How is |
This comment has been minimized.
This comment has been minimized.
|
As in... If we don't know how |
This comment has been minimized.
This comment has been minimized.
|
That being said, even with that it doesn't work (huh, I'd swear we knew how to deal with macro expansions): #define _IO(a_) (a_)
#define UI_DEV_CREATE _IO(1)
#define UI_DEV_DESTROY _IO(2) |
emilio
added
the
enhancement
label
Jun 16, 2017
emilio
changed the title
Nested c macro does not generate any output
Functional C macros are not expanded.
Jun 16, 2017
This comment has been minimized.
This comment has been minimized.
|
This is probably a bug for rust-cexpr. Indeed, it's a dupe of jethrogb/rust-cexpr#3. |
This comment has been minimized.
This comment has been minimized.
|
I guess I can try to add to libclang a way to get whether the macro definition belongs to a functional macro... |
This comment has been minimized.
This comment has been minimized.
nicokoch
commented
Jun 16, 2017
|
If it helps any:
|
This comment has been minimized.
This comment has been minimized.
|
Ok, so libclang provides a |
This comment has been minimized.
This comment has been minimized.
|
I've asked @jethrogb about what the best API for this would be. It shouldn't be a big deal to support it in bindgen once cexpr support is there. |
This comment has been minimized.
This comment has been minimized.
nicokoch
commented
Jun 16, 2017
|
Meanwhile, I used the following in my wrapper.h to workaround the issue: #include <linux/uinput.h>
const __u64 _UI_DEV_CREATE = UI_DEV_CREATE;
#undef UI_DEV_CREATE
const __u64 UI_DEV_CREATE = _UI_DEV_CREATE;
const __u64 _UI_DEV_DESTROY = UI_DEV_DESTROY;
#undef UI_DEV_DESTROY
const __u64 UI_DEV_DESTROY = _UI_DEV_DESTROY; |
This comment has been minimized.
This comment has been minimized.
|
Yeah, note that that would only work in libclang 3.9+ though. |
This comment has been minimized.
This comment has been minimized.
|
Current state: C preprocessor needed. @emilio can you add "help wanted" label? |
fitzgen
added
the
help wanted
label
Jul 26, 2017
jlamb-at-polysync
referenced this issue
May 2, 2018
Open
libsel4-sys: bindgen not expanding functional macros #18
This comment has been minimized.
This comment has been minimized.
clia
commented
Oct 22, 2018
|
How about the progress of this? |
This comment has been minimized.
This comment has been minimized.
|
@clia The state is unchanged as of my latest comment #753 (comment). This issue is marked "help wanted" and waiting for someone (anyone) to implement this functionality. |
nicokoch commentedJun 16, 2017
•
edited
So I'm generating bindings to <linux/uinput>. This works pretty well, but two c macros in particular do not produce any bindings in the output. Reduced input below:
Input C/C++ Header
Bindgen Invocation
wrapper.hlooks like this:Actual Results
No constant
UI_DEV_CREATEorUI_DEV_DESTROYgenerated in output.Expected Results
Constants
UI_DEV_CREATEandUI_DEV_DESTROYgenerated in output.I'm not really that familiar with the kernel macro
_IOand not sure if this is technically even possible, but I figured to report just to get a more professional opinion. If it's not possible, workarounds welcome.