ImportC can now automatically run the preprocessor
max haughton
maxhaton at gmail.com
Mon May 16 04:39:49 UTC 2022
On Monday, 16 May 2022 at 03:12:47 UTC, Walter Bright wrote:
> But I still don't understand - why mixin this stuff? Why would
> someone want to type C code into a D source file?
dpp and dstep are not always able to divine the meaning of a
given macro, so having an escape hatch is either necessary or the
most direct way of doing certain things.
If you use them you can see that they're just looking for
relatively simple patterns, not magic. You can approximate magic
a little by looking at how a macro is used within a source file
(if you're lucky), but extracting this info programmatically
would use a lot of niche infrastructure and thinking that is
probably beyond reachh.
ImportC does not (currently) emit a D equivalent to a header
file, which means that documenting what it actually does for some
non-trivial preprocessor metaprogramming uglyvomityuck is going
to be irritating.
You have a C API, dstep might turn that into a template, which
might be initially confusing but you can just grep (or use an
IDE) for the symbol (or lack thereof if it couldn't do it). With
ImportC this is now much murkier for obvious reasons (although
I'll note that adding a palatable header-output mode is something
I've played around with and honestly wouldn't be particularly
hard as long as we kept a little bit more info around in the
compiler).
So you're in a hurry and you can't seem to get a macro working?
mixinC the bit you need. It's either that or doing it in your
head anyway.
More information about the Digitalmars-d
mailing list