Can we use "ImportC" used yet?

jfondren julian.fondren at gmail.com
Thu Oct 21 23:06:18 UTC 2021


On Thursday, 21 October 2021 at 22:23:50 UTC, data pulverizer 
wrote:
> Hi,
>
> I'm getting an odd issue with ImportC when I import a header 
> converted with `gcc -E -P ...` some of the types signatures in 
> functions don't come through with their proper names but as 
> `__tagXX` where `XX` is some number. It's got to the point 
> where the type itself might get imported correctly, but the 
> same type in a function might be `__tag28` or some other 
> mangled name so when I create an instance of the proper type 
> and try to call the respective function, I get a type error.

I'd first check that the type names look OK in the processed C. 
If they do, then it's an importc bug. Those are still getting 
reported, but yours might be new. Worth checking out.

It might also be a bug that's been fixed since release--try dmd 
master on it. These were fixed a few days ago:

fix Issue 22404 - importC: Error: cannot pass argument 'ENUMMEM' 
of type 'int' to parameter '__tag2
fix Issue 22402 - importC: Error: can't subtract '__tag2[1]' from 
pointer

> Also, with some definitions in the C file, when I try to 
> `#undef` something to get some conditional C definitions to be 
> converted with `gcc -E -P ...`, nothing happens.

d doesn't do any C preprocessing, so any problem here is with 
gcc. Your `#undef`s may be coming before the C preprocessor's own 
`#define`s and have no effect.

> Thanks.




More information about the Digitalmars-d-learn mailing list