The following code fails compile.
#include <stddef.h>
void foo()
{
int *p = NULL;
}
$ clang -fsyntax-only 1.c
1.c:1:10: error: ‘stddef.h’ file not found
#include <stddef.h >
^
1.c:5:12: error: use of undeclared identifier ‘NULL’
int *p = NULL;
^
2 diagnostics generated.
clang should provide its own stddef.h as gcc does. Where should this header go in the directory?
stddef.h lives in the main include directory, so if that's /usr/include it
would be /usr/include/stddef.h.
Do note that stddef.h implements a few platform-specific types. In general,
given a solid include directory resolving, this should not cause problems for
clang on most modern platforms.
If you cannot find stddef.h I'd wager your setup is broken. Did you make sure
to check the include resolving before compiling?
clang currently uses the GCC versions of these files. I'd wager that 'clang -v 1.c' does not list the gcc include directory. To handle this, you have to hack the clang driver to know where to look currently. Search for "FIXME: temporary hack: hard-coded paths" on this page:
http://clang.llvm.org/get_started.html
-Chris