Thread overview
Why doesn't the D compiler include the C preprocessor for importC?
Jan 19, 2023
Ki Rill
Jan 19, 2023
Dave P.
Jan 21, 2023
Walter Bright
January 19, 2023

I am genuinely curious about this. What are the arguments against it?

January 19, 2023
The only one that matters: licensing.

Although once mature I'm sure we can simplify the situation somewhat as part of the Windows installer.
January 19, 2023

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.

January 20, 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.