On Friday, 10 October 2025 at 09:02:33 UTC, Dejan Lekic wrote:
Reading the https://dlang.org/spec/importc.html will help you solve the mystery. This section in particular: https://dlang.org/spec/importc.html#preprocessor

yes, thanks, now it is clear.

Actually my default c pre-processor is my locally compiled cpp (version 16):
which cpp
/usr/local/bin/cpp

and it's used to pre-process the .h files, so then __GNUC__ is 16.

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:

```h
SDL_FORCE_INLINE int SDL_MostSignificantBitIndex32(Uint32 x)
{
#if defined(__GNUC__) && (__GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
    /* Count Leading Zeroes builtin in GCC.
* http://gcc.gnu.org/onlinedocs/gcc-4.3.4/gcc/Other-Builtins.html
     */
    if (x == 0) {
        return -1;
    }
    return 31 - __builtin_clz(x);
#elif
    ...
```
`__builtin_clz` will then be undefined in dmd compiling.


Reply via email to