Add ImportC compiler to dmd

Patrick Schluter Patrick.Schluter at bbox.fr
Mon May 10 07:39:50 UTC 2021


On Monday, 10 May 2021 at 07:21:31 UTC, Walter Bright wrote:
> On 5/9/2021 11:21 PM, Patrick Schluter wrote:
>> [...]
>
> Those linkers were obsoleted in 1990 with the advent of C++ 
> (C++ forced the introduction of COMDAT sections to handle 
> that). D relies on COMDATs, too, so if you're stuck on such an 
> obsolete platform, and I know C wishes to still support them, D 
> won't work on it anyway.
>
>
>> [...]
>
> With COMDATs, this is not a problem.
>
>
>> [...]
>
> Yup.
>
>> [...]
>
> I know. I used to revel in this stuff. Macros that piece 
> together syntax are a horror show, and a big part of why D 
> doesn't have macros. (I eventually removed all this stuff from 
> my C code and it was much nicer as a result.)
>
> There's no way to mechanically translate this stuff to D.
>
> However, the preprocessed code can be compiled just fine by 
> ImportC. You just won't be able to use those macros in the D 
> code. But I'm pretty sure an equivalent can be made by hand.
>
> P.S. that unnamed bit field is, well, sheesh. It could be 
> replaced with a template.

Yes, I just read the comment on your PR and the way chosen is 
indeed the only viable way to proceed.
The only thing that bothers me as it is now is the fact that it 
doesn't support intializer list `{ intializers }`, which I 
suppose means that designated initializers `{ .field = ..., 
[3]=... }`and compound statements `(type){ initializers }` are 
not working either. This would be a real real problem for modern 
C code (C99 and superior).


More information about the Digitalmars-d mailing list