referencing variables declared in an external c file
Frank Benoit
keinfarbton at googlemail.com
Wed Jul 2 13:26:11 PDT 2008
llee schrieb:
> BCS Wrote:
>> somefile.c
>> extern FILE* yyin;
>>
>> header.d:
>> extern(C) FILE* yyin;
>>
>> use.d
>> import header;
>> void main(){writef("%x\n", cast(void*)yyin);}
>>
>>
>> gcc -c somefile.c;
>> dmd -c use.d;
>> dmd use.o somefile.o
>>
>>
> it works.
>
you can link the file if you use
extern extern(C) FILE* yyin;
a dangerous pitfall to forget the first extern.
More information about the Digitalmars-d
mailing list