[cfe-dev] Fwd: clang-cl and INCLUDE path ordering

Jay Foad via cfe-dev cfe-dev at lists.llvm.org
Fri Aug 19 05:09:46 PDT 2016


Hi,

I ran into a problem when switching from cl.exe to clang-cl.exe (3.8.1) for
building a large proprietary Windows application. I'm not sure if this
counts as a bug in clang-cl, but I thought I should report it anyway.

Our app:
- has its own header called cpuid.h
- for obscure reasons, includes all its own headers using angle brackets
instead of double quotes: #include <cpuid.h>

The problem goes like this:

$ cat foo.c
#include <cpuid.h>
T x;

$ cat cpuid.h
typedef int T;

$ INCLUDE=. cl /c foo.c # works

$ INCLUDE=. clang-cl /c foo.c # doesn't work
foo.c(2,1) :  error: unknown type name 'T'

... because it has picked up the cpuid.h shipped with clang-cl, not the one
in the current directory.

A few experiments with cl suggest that it looks for headers in these
directories, in this order:
1. /I command line options
2. INCLUDE environment variable
3. C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include

Whereas clang-cl -Xclang -v tells me it is looking in:
1. /I command line options
2. C:\Program Files\LLVM\bin\..\lib\clang\3.8.1\include
3. INCLUDE environment variable

Any chance of swapping 2 and 3 round, to better match cl?

Thanks,
Jay.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160819/c0a65c6e/attachment-0001.html>


More information about the cfe-dev mailing list