Question

I was looking through the libclang headers here(http://llvm.org/svn/llvm-project/cfe/trunk/include/clang-c/) where in I noticed that almost all of the headers have imports as in

#include "clang-c/Platform.h" // in CXString.h

// in Index.h
#include "clang-c/Platform.h"
#include "clang-c/CXString.h"

I'm unable to understand why the headers are prefixed with clang-c/ since all of them are in the same directory shouldn't it rather have been ./Platform.h ./CXString.h and likewise.

Was it helpful?

Solution

If the headers end up installed in /usr/local/include/clang-c directory, for sake of argument, then the command line option -I /usr/local/include will ensure that #include "clang-c/Platform.h" is found. If the subdirectory was not specified, you'd have to have -I /usr/local/include/clang-c on the command line. It also provides partitioning and separation; the clang-c/Platform.h is separate from a file Platform.h from any other package.

Note that the headers such as <sys/wait.h> use this scheme, but the sys in question is the O/S and the headers are found in /usr/include/sys (but you do not have to specify -I /usr/include/sys on the compiler command line because the preprocessor already searches in /usr/include by default).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top