ImportC can now automatically run the preprocessor
Adam D Ruppe
destructionator at gmail.com
Mon May 16 13:22:26 UTC 2022
On Monday, 16 May 2022 at 03:12:47 UTC, Walter Bright wrote:
> This is replacing C #define's with D constructions, right?
No. It is about not having to. Instead of converting to D (and
being forced to fail in certain cases), you just mixinC.
> I'm not going to pretend this can ever be a complete 100%
> solution, after all:
>
> #define BEGIN {
> #define END }
>
> What can one do with that? Phooey.
This is an example I showed *can actually work* in the message
you're quoting. Of course, they'd have to be paired in the mixed
in block, but it would work once you get a complete ast node
assembled.
Very similar to D's
enum string BEGIN = "{";
enum string END = "}";
mixin(BEGIN ~ "stuff" ~ END);
mixin(BEGIN) obviously not going to work, but if you concat the
strings to form a complete statement, you have something that can
be used.
The C preprocessor is very similar to string replacement and
concatenation.
> But I still don't understand - why mixin this stuff?
> Why would someone want to type C code into a D source file?
Why would someone want to use inline assembler? Why would someone
want to use CTFE on C? Why would someone want to type __import in
a C file?
More information about the Digitalmars-d
mailing list