[clang] [Headers] Don't declare unreachable() from stddef.h in C++ (PR #86748)

Nick Desaulniers via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 29 09:48:09 PDT 2024


nickdesaulniers wrote:

> I think I am generally deeply confused about what should be provided by the compiler and what should be provided by the C Standard Library on any given platform.

+1

> Doing otherwise and trying to be "helpful" in Clang only creates confusion and forces C libraries to jump through hoops to avoid colliding with stuff already defines in Clang builtin headers.
> I believe we should basically not provide any Clang builtin headers except the ones that clearly provide compiler-related stuff (e.g. <stdarg.h> or tmmintrin.h & friends).

Weak +1 (+1, but similar levels of unsuredness).

---
On the llvm-libc side, we're running into pain with some of the compiler provided headers, too, particularly because they tend to themselves include additional headers (the xmm intrinsic headers including stdlib for example).  I'm very tempted to resort to `-nostdinc` and just have our own definitions for everything:

```c
typedef __SIZE_TYPE__ size_t;
...
```
and just be done with compiler resource headers.

---
I'll suspect that `#define __need_foo` `#include <stddef.h>` pattern makes precompiling stddef.h impossible.
---
cc @enh for visibility.

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


More information about the cfe-commits mailing list