[PATCH] D157757: [Headers] Replace __need_STDDEF_H_misc with specific __need_ macros

Louis Dionne via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 18 15:06:35 PDT 2023


ldionne added a comment.

This is going to be really naive, but can someone explain why we need these `__need_XXXXX` macros? Why doesn't `<stddef.h>` simply always declare what it should declare? Also, does anybody understand the expected relationship between the C Standard Library headers and these Clang builtin headers? Who defines what?

Everyone I've spoken to so far about this (and myself) was extremely confused. At some point I thought these macros were only needed for compatibility with old glibcs but that wouldn't even be needed anymore, but I'm not certain.



================
Comment at: clang/lib/Headers/stddef.h:118-122
+#ifdef __cplusplus
+namespace std {
+typedef decltype(nullptr) nullptr_t;
+}
+using ::std::nullptr_t;
----------------
iana wrote:
> aaron.ballman wrote:
> > Related:
> > 
> > https://github.com/llvm/llvm-project/issues/37564
> > https://cplusplus.github.io/LWG/issue3484
> > 
> > CC @ldionne
> I don't _think_ this change actually changes the way nullptr_t gets defined in C++, does it?
I think we absolutely don't want to touch `std::nullptr_t` from this header. It's libc++'s responsibility to define that, and in fact we define it in `std::__1`, so this is even an ABI break (or I guess it would be a compiler error, not sure).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157757/new/

https://reviews.llvm.org/D157757



More information about the cfe-commits mailing list