ImportC and nothrow/@nogc?

Jonathan M Davis newsgroup.d at jmdavisprog.com
Fri Aug 30 04:16:25 UTC 2024


On Thursday, August 29, 2024 1:50:10 PM MDT Steven Schveighoffer via 
Digitalmars-d wrote:
> On Thursday, 29 August 2024 at 19:32:06 UTC, Stefan Koch wrote:
> > That requires modification of the C header.
> > maybe using the attribute on the import is a better idea.
> > Perhaps it is reasonable to have both, but I can imagine people
> > not wanting to change their headers.
>
> You can't import headers with importC. You have to import C files.

I was _really_ confused when I found that out, and I have no clue why it was
done that way, since you don't normally #include .c files.

> It is already necessary to create shim C files.
>
> So in the shim, you set the attributes, and import the headers
> you need.

I do think that it's kind of dumb that you can't just import C headers with
importC, since it seems like that would be the obvious thing that you're
trying to do, but putting something in a shim file to affect the attributes
isn't terrible when you already have to have one.

- Jonathan M Davis





More information about the Digitalmars-d mailing list