Add ImportC compiler to dmd

Iain Buclaw ibuclaw at gdcproject.org
Fri May 14 13:44:21 UTC 2021


On Friday, 14 May 2021 at 05:27:27 UTC, Walter Bright wrote:
> On 5/13/2021 2:04 PM, Iain Buclaw wrote:
>> Well, either one of, or two things will happen:
>> 
>> 1. People will raise bugs against dmd because `gdc foo.c` will 
>> be able to compile more code than dmd (and do preprocessing).
>> 
>> 2. People will raise bugs against gdc because `gdc -finline 
>> foo.c bar.d` doesn't inline C functions into bar.
>> 
>> I meant conflicts will happen if I change the current behavior 
>> so make it so the D compiler handles C sources too i.e: `d21 
>> bar.d foo.c -o bar.o`.
>
> Understood.
>
> It's pretty clear that ImportC is not going to be an exact 
> clone of gcc. I've been looking over the __attribute__ 
> documentation, and there doesn't even seem to be a proper 
> grammar for it.
>
> https://gcc.gnu.org/onlinedocs/gcc/Attribute-Syntax.html#Attribute-Syntax
>
> There's some wishy-washy wording:
>

I guess in the D grammar, the closest approximation of an 
attribute-list is just a comma delimited list of call expressions.

__attribute__( (fun1, fun2(2), fun3("bar"), fun4(5, 6)) )

Failing that, just accept any token, until you see the matching 
closing parenthesis.  Parsing it can be postponed until the 
semantic phase, same as asm.


More information about the Digitalmars-d mailing list