On 09/09/2026 5:14 AM, Rambutan wrote:
On Tuesday, 8 September 2026 at 07:34:09 UTC, Richard (Rikki) Andrew
Cattermole wrote:
On 08/09/2026 6:31 PM, Rambutan wrote:
This is apparently a bug, as D interface files containing only simple
type definitions to replace C header files in D source like di.di are
supposed to behave like header files.
No they are not.
D generates metadata that must be compiled in.
.di files can only exist as derivatives of D files that have been
linked in.
Ah, I see! Does this mean that officially .di files are not intended as
a mechanism to provide C header file information to D, and so such a use
is a technical exercise pushing the envelope?
Yes, basically.
Hence why they are generated by the compiler with the help of a compiler
switch. Your not meant to make them yourself, although you can, after
all they are regular d files with a different file extension.
This use of .di files with C is the only one I have encountered in
practice, and they have been generated automatically from C header files
and edited to smooth out any wrinkles. Until this encounter with doubles
in structs this has all worked fine with no compilation of the .di file.
https://github.com/dlang/dmd/blob/master/druntime/src/core/stdc/stdio.d
Things work, right up until it doesn't work.