[cfe-commits] [patch] Let NULL and MSVC headers coexist

David Blaikie dblaikie at gmail.com
Tue Apr 24 14:07:07 PDT 2012


On Tue, Apr 24, 2012 at 2:03 PM, Nico Weber <thakis at chromium.org> wrote:
> On Tue, Apr 24, 2012 at 2:02 PM, David Blaikie <dblaikie at gmail.com> wrote:
>> On Tue, Apr 24, 2012 at 1:49 PM, Nico Weber <thakis at chromium.org> wrote:
>>> Hi,
>>>
>>> the attached patch fixes both issues mentioned in
>>> http://llvm.org/PR12146 . Like suggested by Eli in that bug, it does
>>> this by defining NULL to 0 instead of __null on windows. I think it
>>> would be nice to have a __clang_null, but this patch fixes the
>>> immediate issues I'm seeing without me having to argue with Eli :-)
>>> Maybe I'll do that in a follow-up patch.
>>
>> I'm probably with you on the __clang_null - ish, but if "better
>> diagnostics"* isn't something Eli considers a "necessary" basis for
>> making that change, I guess not.
>>
>> * Currently our null-conversion warnings are off by default & not very
>> good (big holes in them - int i = NULL doesn't warn when sizeof(void*)
>> == sizeof(int)). Also, technically we could implement these warnings
>> without __null anyway, by looking at the spelling of every zero
>> literal in a program... but perhaps that would be prohibitive.
>>
>>> Ok?
>>
>> Could you potentially test both these cases in the same source file?
>> Just to keep test file count down.
>
> No, because stddef.h has file include guards.

Right, but wouldn't this still exercise both cases you were demonstrating:

#define __null

#include <stddef.h>

void f(__null void* p) {}

#undef __null
#define __null

void* p = NULL;

It misses some subcases, but covers the cases you documented/described
in the mail/bug. (this is just a thought, not a request/requirement by
any means)

- David



More information about the cfe-commits mailing list