Is `__GNUC__` defined in dmd when using importC?

Paul Backus snarwin at gmail.com
Fri Oct 10 16:15:05 UTC 2025


On Friday, 10 October 2025 at 10:06:39 UTC, felixfxu wrote:
> But that introduce another question: dmd is not a complete gcc 
> replacement I guess, but in the headers, all `#ifdef __GNUC__` 
> is `true`, it will have problems for code like this:

As a workaround, you can use [DMD's `-P` switch][1] and [GCC's 
`-U` switch][2] to disable any macros that cause problems. For 
example, `-P=-U__GNUC__` would disable the `__GNUC__` macro.

[1]: https://dlang.org/dmd-linux.html#switch-P
[2]: 
https://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html#index-U


More information about the Digitalmars-d-learn mailing list