[clang] [C99] Remove the tgmath.h header (PR #135236)
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 10 13:58:07 PDT 2025
zygoloid wrote:
I see. The glibc header comment gives an idea of what's going on here:
```c
/* There are two variant implementations of type-generic macros in
this file: one for GCC 8 and later, using __builtin_tgmath and
where each macro expands each of its arguments only once, and one
for older GCC, using other compiler extensions but with macros
expanding their arguments many times (so resulting in exponential
blowup of the size of expansions when calls to such macros are
nested inside arguments to such macros). */
```
Indeed, it seems that `_Generic` is not sufficient to implement the `<tgmath.h>` macros without expanding the arguments at least twice each, and in any case glibc doesn't have an implementation that uses `_Generic`.
So it looks like the world is thoroughly unprepared for us to not provide our own `<tgmath.h>` in general. We could add a builtin matching the GCC `__builtin_tgmath` builtin and remove our header for at least those targets, though. And we should find out what other libc implementations are doing.
https://github.com/llvm/llvm-project/pull/135236
More information about the cfe-commits
mailing list