[PATCH] D140250: Define NULL in its own header

Ian Anderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 25 13:08:58 PST 2023


iana added a comment.

In D140250#4081044 <https://reviews.llvm.org/D140250#4081044>, @aaron.ballman wrote:

> In D140250#4081009 <https://reviews.llvm.org/D140250#4081009>, @iana wrote:
>
>> In D140250#4080990 <https://reviews.llvm.org/D140250#4080990>, @rsmith wrote:
>>
>>> Wait a second... if an OS wants only `NULL`, we already have a supported way of achieving that, which is compatible with GCC and glibc and other POSIX compilers -- define `__need_NULL` before including the header.
>>>
>>> We shouldn't be providing internal headers with `__mangled_names` for OSes to include, those should be implementation details.
>>
>> You can't do that with modules though, `#define __need_NULL #include <stddef.h>` doesn't work.
>
> Also, from the patch summary: ` i.e. in POSIX headers that are required to define NULL but not the rest of stddef.h.` -- I don't think `__need_NULL` works for this because it gets you `NULL` but it also gets you the rest of the stddef.h header, right?

Once you set one of the `__need` macros, then stddef.h will //only// give you those definitions. (Or I'm interpreting the file gravely wrong... it's kind of a weird header and its customizations don't really work with modules either.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140250



More information about the llvm-commits mailing list