Why doesn't the D compiler include the C preprocessor for importC?

Walter Bright newshound2 at digitalmars.com
Sat Jan 21 01:46:09 UTC 2023


On 1/18/2023 9:49 PM, Dave P. wrote:
> On Thursday, 19 January 2023 at 05:04:11 UTC, Ki Rill wrote:
>> I am genuinely curious about this. What are the arguments against it?
> 
> The main reason is that other compilers/platforms define a huge number of macros 
> and extensions that real header files depend on. There is already a C 
> preprocessor written in D (https://github.com/walterbright/warp) that could be 
> used, but there’s an endless parade of predefined macros.

You're right. It's (surprisingly) not that those preprocessors implement 
extensions. It's that they predefine several hundred macros, many of them being 
dependent on various switches. The documentation on it is weak to wrong to 
nonexistent, so one is faced with quite a problem trying to duplicate it. And 
then, of course, the behavior will change on the next release.

It's like chasing a rainbow.


More information about the Digitalmars-d mailing list