Would it be theoretically possible to use string mixins, CTFE, and import expressions (using the -J switch) to write a function cHeaderInclude such that it may be used like:

mixin( cHeaderInclude( import( "someheader.h" ) ) );


I'm imagining that the cHeaderInclude function would parse the C code from the header, convert it to D declarations at compile time, and then returns those declarations to be mixed in, just like an #include would do.

Preprocessor defines could be handled with extra parameters: "SOME_DEF=1, ANOTHER_DEF=foo" etc.

Am I missing something that would make this impossible?

Reply via email to