[LLVMbugs] [Bug 12997] New: #define NULL __null gets redefined to 0 in linux
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Thu May 31 10:06:48 PDT 2012
http://llvm.org/bugs/show_bug.cgi?id=12997
Bug #: 12997
Summary: #define NULL __null gets redefined to 0 in linux
Product: clang
Version: trunk
Platform: PC
OS/Version: Windows XP
Status: NEW
Severity: enhancement
Priority: P
Component: Headers
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: rodrigorivascosta at gmail.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
Hello.
I have a problem with the NULL macro in linux. Consider the following program:
#include <sys/wait.h>
int main()
{
void *p = NULL;
}
If I precompile it with 'g++ -E a.cpp' I get:
...
# 2 "a.cpp" 2
int main()
{
void *p = __null;
}
Which is the expected result. But with 'clang++ -E a.cpp':
...
# 2 "a.cpp" 2
int main()
{
void *p = 0;
}
Which is wrong!
I've traced the problem, and the NULL macro is redefined in
'/usr/include/linux/stddef.h' in both cases, but after including that that the
system headers have the following code:
# define __need_NULL
# include <stddef.h>
The difference here is that the 'stddef.h' from gcc redefines the NULL again,
but the one from clang does not.
Regards.
--
Rodrigo
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list