mozilla / cbindgen

A project for generating C bindings from Rust code
Mozilla Public License 2.0
2.43k stars 314 forks source link

[Feature Request] Const of unit type generate "empty" defines #1017

Open GrayJack opened 4 weeks ago

GrayJack commented 4 weeks ago

In my project, depending on the target some definitions should expand to nothing instead of a number.

I would like that if a const defined as a unit type generated an empty define: const MYCONST: () = () —> #define MYCONST

Currently I'm using a hack, since I do have a header that are included on all other headers, I create a manual #define None and make the const equal to None. That in turns generate #define [NAME] None, in the grand scheme of things, C preprocessor expand to nothing, as expected. But would be nice to have something easier and less hacky.