[patch] Let stddef.h redefine NULL if __need_NULL is set
Nico Weber
thakis at chromium.org
Tue Apr 29 17:22:32 PDT 2014
That's good to know!
I checked that the problem reproduces on debian wheezy (debian's current
stable, a bit less than a year old), but it is fixed on debian sid.
So applications could work around this by doing "mkdir -p hack/linux; touch
hack/linux/stddef.h" and then adding "-Ihack" to all their commandlines
until this is fixed. Since this is only needed for a limited time (2
years-ish), that seems preferable to me over adding hacks to clang's
headers. Any other opinions? If not, I'll drop this patch.
In any case, it's probably a good idea to change stddef.h so that the
already-present __need_wint_t behaves like in gcc's version: if that's
defined, stddef.h only provides win_t and does nothing else. Should I send
a patch for just that?
On Tue, Apr 29, 2014 at 7:35 AM, Lubos Lunak <l.lunak at centrum.cz> wrote:
> On Monday 28 of April 2014, Reid Kleckner wrote:
> > Even if we commit this workaround, can we report this as a bug to
> upstream
> > Linux?
>
> Already done (http://comments.gmane.org/gmane.linux.kernel/1281756). And
> there's actually no public #define NULL in recent Linux headers.
>
> > The test case you have shows how this definition of NULL is broken
> > on x86_64, even in C with gcc:
> >
> > $ cat t.c
> > #define NULL 0
> > int printf(const char *, ...);
> > int main() {
> > printf("%d %d %d %d %d %d %p\n", 1, 2, 3, 4, 5, 6,
> > 0xdeadbeefdeadbeefULL); printf("%d %d %d %d %d %d %p\n", 1, 2, 3, 4, 5,
> 6,
> > NULL);
> > }
> >
> > $ gcc -w t.c -o t && ./t
> > 1 2 3 4 5 6 0xdeadbeefdeadbeef
> > 1 2 3 4 5 6 0xdeadbeef00000000
>
> --
> Lubos Lunak
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140429/c6cdd04b/attachment.html>
More information about the cfe-commits
mailing list