Fixes https://github.com/dlang/dmd/issues/21271
Redefine the compatibility macro in terms of C99's `_Pragma()`
instead of ignoring it. Clang and GCC will replace `_Pragma()`
with `#pragma` directives in the preprocessed output, while
cl.exe will actually convert it back to `__pragma()`.
This is still a better situation than before as ImportC partially
supports `__pragma()`.
Fixes https://github.com/dlang/dmd/issues/18263
Command to invoke the preprocessor wasn't quoting paths.
This isn't bulletproof and really the interface should be taking an
array of strings or use a command-builder type pattern, but this
resolves the common issue of paths with spaces in them.
Fixes https://github.com/dlang/dmd/issues/21241
C Static functions were being given the same externally mangled
name as their identifier, which caused only one to be picked
when linking with linkers that supported that.
Additionally, the dmd glue code was only outputting one of these
static functions as a workaround for a different linker issue.
Solve this by giving C static functions a unique name (by using D
mangling) and adding an `isStatic()` check to the dmd glue hack.
Fixes https://github.com/dlang/dmd/issues/20499
Fixes https://github.com/dlang/dmd/issues/20963
ImportC deferred declaring "tagged" types (structs/unions/enums)
until after it saw a possible typedef so that the identifier for
a typedef declaration like:
typedef struct { int x; } Foo;
would give the struct the name Foo. In several circumstances,
this led to tagged types not being declared. Resolve this by
chasing down those circumstances.
Also, there were other circumstances where types weren't being
correctly declared which caused other issues. Lock those down.
Fixes: https://github.com/dlang/dmd/issues/18127
When merging struct definitions from different C imports, check that the
structs are actually compatible according to the C rules. If they are
not, issue an error.
Previous iteration of this did not properly account for the interaction
of aligned and packed and would even segfault on a null access in such
a case. This version properly handles that interaction by aligning the
struct itself instead of the first member and not forcing the struct
alignment to 1 if it is packed.
Fixes https://github.com/dlang/dmd/issues/20423
Ultimate cause of this issue was that va_arg was being shadowed
by the collected template-like macros. As va_arg is not a normal
function (it takes a type as a parameter), this interfered with
the cparser's rewrite of va_arg to a call to the single argument
template version in core.stdc.stdarg.
Fixes: https://github.com/dlang/dmd/issues/20334
After preprocessing, #defines in C code that are just string literals
are converted into D enums. As these are collected for use in D code,
they should behave like D string literals and not C string literals.
This is just a byproduct of taking a closer look at this code,
as part of investigating the recent CI failures on Windows, where
the VERSION and SYSCONFDIR.imp rules seem to run twice - and then
fail for the 2nd run, Windows complaining about another process using
the file. I guess that could be an Anti-malware process running right
after creating the file the first time. And both rules check the file
contents as part of their condition, so if the rule is processed twice,
we try to immediately read its contents after the write.
Each of these 2 auto-generated files is string-imported exactly once:
* `SYSCONFDIR.imp` in the driver's `dmd/dinifile.d` (and actually on
Posix only)
* `VERSION` in the lexer's `dmd/globals.d`
I've revised the deps accordingly, which might avoid processing these
rules multiple times as a side-effect.