[clang] [clang][headers] Including stddef.h always redefines NULL (PR #99727)
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 19 18:08:09 PDT 2024
================
@@ -49,7 +48,25 @@
#define __need_rsize_t
#endif
#define __need_wchar_t
+#if !defined(__STDDEF_H) && !__building_module(_Builtin_stddef)
----------------
zygoloid wrote:
I'm not sure that the second condition here makes any difference: I'd think the only way we could get here with `__building_module(_Builtin_stddef)` evaluating to `true` is if one of the modular headers in that module (`__stddef_*.h`) were to recursively include `stddef.h`, which it seems they shouldn't be doing! Also, given that we have the actual definition of the `NULL` macro in a non-textual module of its own these days, it doesn't seem like the problem described below would actually happen.
Can we drop the `__building_module` check here?
I also wonder if we can move the `!defined(__STDDEF_H)` condition up to the `#if` on line 38 -- if we've already had a full include of the entirety of `<stddef.h>`, we shouldn't `__need` anything, whether it's a macro or something else.
https://github.com/llvm/llvm-project/pull/99727
More information about the cfe-commits
mailing list