[clang] [C99] Remove the tgmath.h header (PR #135236)

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 10 12:35:33 PDT 2025


zygoloid wrote:

> Background: it's not clear to me which C Standard Library headers Clang should or should not provide,

Historically, the easiest line to draw has been that we aim to provide the freestanding headers. This matches GCC's [documented position](https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/Standards.html#C-Language:~:text=GCC%20aims%20towards%20being%20usable%20as%20a%20conforming%20freestanding%20implementation%2C%20or%20as%20the%20compiler%20for%20a%20conforming%20hosted%20implementation.) that it provides a complete conforming freestanding implementation, or the compiler for a hosted implementation.

For some reason, WG21 has trampled over that meaning of "freestanding" and we no longer have such a separation for C++, but it still exists for C, so it makes sense to still follow it there. And `<tgmath.h>` isn't a freestanding header.

There are sometimes other reasons why we might feel like we should be providing a header rather than leaving it to the C standard library implementation, and in particular `<tgmath.h>` used to be unimplementable in standard C, which was one such reason (we implemented it with `__attribute__((overloadable))` before `_Generic` existed). But that's not been true for a long time. Another such reason is that the system header for the target doesn't work with Clang, which sounds like it is the case for AIX, so that's a good reason to keep it :)

I wonder if we can put it into an AIX-only (plus whatever other targets still need it) include directory, though, so we only find and use it on the targets where it's necessary?

https://github.com/llvm/llvm-project/pull/135236


More information about the cfe-commits mailing list