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

Ian Anderson via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 22 11:33:55 PDT 2023


iana added inline comments.


================
Comment at: clang/lib/Headers/stddef.h:1
 /*===---- stddef.h - Basic type definitions --------------------------------===
  *
----------------
aaron.ballman wrote:
> ldionne wrote:
> > Making a thread out of this:
> > 
> > > The relationship between clang's stddef.h and the C Standard Library stddef.h is that there is no relationship. clang's header doesn't #include_next, and it is in the search path before the OS's cstdlib.
> > 
> > So in that case what is the purpose of the SDK/system providing a `<stddef.h>` header? They basically all provide one and it's never used?
> > 
> The compiler provides `<stddef.h>` for the same reason it provides `<limits.h>` and others: the compiler is responsible for defining these interfaces because it's the only thing that knows the correct definitions it expects. The system might know some of it, but for example, `size_t` relates to the maximum size of an object, which is something only the compiler knows the answer to.
I think the purpose is for the SDK/system to support compilers that don't provide `<stddef.h>`. In the early Apple days that was CodeWarrior, maybe gcc didn't used to provide that header? I don't know.

But basically yes, they all provide one and it's practically never used.


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