[cfe-dev] Stop Clang from including problem headers from visual studio 11

Reid Kleckner rnk at google.com
Thu May 9 08:27:10 PDT 2013


Whoops, looks like even if you unset %INCLUDE% clang still falls back
to heuristics to find MSVC's headers.

Looking at the code in clang/lib/Driver/WindowsToolChain.cpp shows you
can pass -nostdinc to turn this all off.

On Thu, May 9, 2013 at 9:55 AM, Kim <soldoutseashell at gmail.com> wrote:
> Hi, thanks for the response.
>
> Is there some command I can use to stop clang from automatically including
> any directories so I can just specify my own?
>
>
> On 5/9/2013 5:25 AM, Reid Kleckner wrote:
>>
>> You most likely need to remove INCLUDE from your environment.  The
>> clang driver forwards that var to the -cc1 command line, which I think
>> is what's happening here.
>>
>> On Wed, May 8, 2013 at 5:19 PM, Kim <soldoutseashell at gmail.com> wrote:
>>>
>>> Hi guys,
>>>
>>> I'm having an issue with some headers from VS11 that clang is
>>> automatically
>>> including. This is a problem that I haven't been able to find info on but
>>> I'm happy to just use the VS 10 headers unless someone knows how to fix
>>> the
>>> problem with VS11. So my question: how do I stop the clang driver from
>>> automatically adding VS 11 to the isystem includes?
>>>
>>> The only reference I found to my problem online was this:
>>> http://lists.cs.uiuc.edu/pipermail/llvmbugs/2013-January/026857.html
>>>
>>> Here's the errors that come up with VS 11
>>>
>>> C:\Program Files (x86)\LLVM\build\bin\Debug>clang++.exe -v -o test.o
>>> test.cpp -c -I "C:\Program Files (x86)\Microsoft
>>> SDKs\Windows\v7.0A\include"
>>> -resource-dir "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\"
>>> clang version 3.3 (trunk)
>>> Target: i686-pc-win32
>>> Thread model: posix
>>>   "C:/Program Files (x86)/LLVM/build/bin/Debug/clang++.exe" -cc1 -triple
>>> i686-pc-win32 -emit-obj -mrelax-all -disable-free -main-file-name
>>> test.cpp
>>> -mrelocation-model static -mdisable-fp-elim -fmath-errno -masm-verbose
>>> -mconstructor-aliases -target-cpu pentium4 -v -coverage-file test.o
>>> -resource-dir "C:\\Program Files (x86)\\Microsoft Visual Studio
>>> 10.0\\VC\""
>>> -I "C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\include"
>>> -internal-isystem "C:/Program Files (x86)/Microsoft Visual Studio
>>> 10.0/VC\""
>>> -internal-isystem "C:\\Program Files (x86)\\Microsoft Visual Studio
>>> 11.0\\VC\\include" -internal-isystem "C:\\Program Files (x86)\\Windows
>>> Kits\\8.0\\\\include" -std=c++11 -fdeprecated-macro -ferror-limit 19
>>> -fmessage-length 150 -mstackrealign -fms-extensions -fms-compatibility
>>> -fmsc-version=1300 -fdelayed-template-parsing -fobjc-runtime=gcc
>>> -fobjc-default-synthesize-properties -fcxx-exceptions -fexceptions
>>> -fdiagnostics-show-option -fcolor-diagnostics -backend-option
>>> -vectorize-loops -o test.o -x c++ test.cpp
>>> clang -cc1 version 3.3 based upon LLVM 3.3svn default target
>>> i686-pc-win32
>>> #include "..." search starts here:
>>> #include <...> search starts here:
>>>   C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include
>>>   C:/Program Files (x86)/Microsoft Visual Studio 10.0/VC"
>>>   C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include
>>>   C:\Program Files (x86)\Windows Kits\8.0\\include
>>> End of search list.
>>> In file included from test.cpp:3:
>>> In file included from C:\Program Files (x86)\Microsoft Visual Studio
>>> 11.0\VC\include\map:6:
>>> In file included from C:\Program Files (x86)\Microsoft Visual Studio
>>> 11.0\VC\include\xtree:6:
>>> In file included from C:\Program Files (x86)\Microsoft Visual Studio
>>> 11.0\VC\include\xmemory:6:
>>> In file included from C:\Program Files (x86)\Microsoft Visual Studio
>>> 11.0\VC\include\xmemory0:9:
>>> In file included from C:\Program Files (x86)\Microsoft Visual Studio
>>> 11.0\VC\include\xutility:8:
>>> In file included from C:\Program Files (x86)\Microsoft Visual Studio
>>> 11.0\VC\include\utility:8:
>>> In file included from C:\Program Files (x86)\Microsoft Visual Studio
>>> 11.0\VC\include\type_traits:1820:
>>> C:\Program Files (x86)\Microsoft Visual Studio
>>> 11.0\VC\include\xrefwrap:156:21: error: too many arguments provided to
>>> function-like macro invocation
>>> _VARIADIC_EXPAND_0X(_CLASS_RESULT_OF_PF_OPT_0X, , , , )
>>>                      ^
>>> C:\Program Files (x86)\Microsoft Visual Studio
>>> 11.0\VC\include\xstddef:652:22: note: expanded from macro
>>> '_VARIADIC_EXPAND_0X'
>>>          _VARIADIC_EXPAND_1X(FUNC, X1, X2, X3, X4)
>>>                              ^
>>> C:\Program Files (x86)\Microsoft Visual Studio
>>> 11.0\VC\include\xstddef:655:21: note: expanded from macro
>>> '_VARIADIC_EXPAND_1X'
>>>          _VARIADIC_EXPAND_1(FUNC, X1, X2, X3, X4) \
>>>                             ^
>>> C:\Program Files (x86)\Microsoft Visual Studio
>>> 11.0\VC\include\xstddef:531:50: note: expanded from macro
>>> '_VARIADIC_EXPAND_1'
>>> #define _VARIADIC_EXPAND_1(FUNC, X1, X2, X3, X4) \
>>>                                                   ^
>>> C:\Program Files (x86)\Microsoft Visual Studio
>>> 11.0\VC\include\xrefwrap:154:19: note: expanded from macro
>>> '_CLASS_RESULT_OF_PF_OPT_0X'
>>>                          __cdecl, X2, X3, X4)
>>>                                         ^
>>> C:\Program Files (x86)\Microsoft Visual Studio
>>> 11.0\VC\include\xstddef:949:9: note: macro '_VARIADIC_CALL_OPT_X1'
>>> defined
>>> here
>>> #define _VARIADIC_CALL_OPT_X1(FUNC, X1, X2, X3, X4, \
>>>          ^
>>> In file included from test.cpp:3:
>>> In file included from C:\Program Files (x86)\Microsoft Visual Studio
>>> 11.0\VC\include\map:6:
>>> In file included from C:\Program Files (x86)\Microsoft Visual Studio
>>> 11.0\VC\include\xtree:6:
>>> In file included from C:\Program Files (x86)\Microsoft Visual Studio
>>> 11.0\VC\include\xmemory:6:
>>> In file included from C:\Program Files (x86)\Microsoft Visual Studio
>>> 11.0\VC\include\xmemory0:9:
>>> In file included from C:\Program Files (x86)\Microsoft Visual Studio
>>> 11.0\VC\include\xutility:8:
>>> In file included from C:\Program Files (x86)\Microsoft Visual Studio
>>> 11.0\VC\include\utility:8:
>>> In file included from C:\Program Files (x86)\Microsoft Visual Studio
>>> 11.0\VC\include\type_traits:1820:
>>> C:\Program Files (x86)\Microsoft Visual Studio
>>> 11.0\VC\include\xrefwrap:156:21: error: too many arguments provided to
>>> function-like macro invocation
>>> _VARIADIC_EXPAND_0X(_CLASS_RESULT_OF_PF_OPT_0X, , , , )
>>>                      ^
>>> C:\Program Files (x86)\Microsoft Visual Studio
>>> 11.0\VC\include\xstddef:652:22: note: expanded from macro
>>> '_VARIADIC_EXPAND_0X'
>>>          _VARIADIC_EXPAND_1X(FUNC, X1, X2, X3, X4)
>>>                              ^
>>> C:\Program Files (x86)\Microsoft Visual Studio
>>> 11.0\VC\include\xstddef:656:22: note: expanded from macro
>>> '_VARIADIC_EXPAND_1X'
>>>          _VARIADIC_EXPAND_2X(FUNC, X1, X2, X3, X4)
>>>                              ^
>>> C:\Program Files (x86)\Microsoft Visual Studio
>>> 11.0\VC\include\xstddef:596:21: note: expanded from macro
>>> '_VARIADIC_EXPAND_25'
>>>          _VARIADIC_EXPAND_2(FUNC, X1, X2, X3, X4) \
>>>                             ^
>>> C:\Program Files (x86)\Microsoft Visual Studio
>>> 11.0\VC\include\xstddef:534:50: note: expanded from macro
>>> '_VARIADIC_EXPAND_2'
>>> #define _VARIADIC_EXPAND_2(FUNC, X1, X2, X3, X4) \
>>>                                                   ^
>>> C:\Program Files (x86)\Microsoft Visual Studio
>>> 11.0\VC\include\xrefwrap:154:19: note: expanded from macro
>>> '_CLASS_RESULT_OF_PF_OPT_0X'
>>>                          __cdecl, X2, X3, X4)
>>>                                         ^
>>> C:\Program Files (x86)\Microsoft Visual Studio
>>> 11.0\VC\include\xstddef:949:9: note: macro '_VARIADIC_CALL_OPT_X1'
>>> defined
>>> here
>>> #define _VARIADIC_CALL_OPT_X1(FUNC, X1, X2, X3, X4, \
>>>          ^
>>> In file included from test.cpp:3:
>>> In file included from C:\Program Files (x86)\Microsoft Visual Studio
>>> 11.0\VC\include\map:6:
>>> In file included from C:\Program Files (x86)\Microsoft Visual Studio
>>> 11.0\VC\include\xtree:6:
>>> In file included from C:\Program Files (x86)\Microsoft Visual Studio
>>> 11.0\VC\include\xmemory:6:
>>> In file included from C:\Program Files (x86)\Microsoft Visual Studio
>>> 11.0\VC\include\xmemory0:9:
>>> In file included from C:\Program Files (x86)\Microsoft Visual Studio
>>> 11.0\VC\include\xutility:8:
>>> In file included from C:\Program Files (x86)\Microsoft Visual Studio
>>> 11.0\VC\include\utility:8:
>>> In file included from C:\Program Files (x86)\Microsoft Visual Studio
>>> 11.0\VC\include\type_traits:1820:
>>> C:\Program Files (x86)\Microsoft Visual Studio
>>> 11.0\VC\include\xrefwrap:156:21: error: unknown type name
>>> '_VARIADIC_CALL_OPT_X1'
>>> _VARIADIC_EXPAND_0X(_CLASS_RESULT_OF_PF_OPT_0X, , , , )
>>>                      ^
>>> C:\Program Files (x86)\Microsoft Visual Studio
>>> 11.0\VC\include\xstddef:652:22: note: expanded from macro
>>> '_VARIADIC_EXPAND_0X'
>>>          _VARIADIC_EXPAND_1X(FUNC, X1, X2, X3, X4)
>>>                              ^
>>> C:\Program Files (x86)\Microsoft Visual Studio
>>> 11.0\VC\include\xstddef:655:21: note: expanded from macro
>>> '_VARIADIC_EXPAND_1X'
>>>          _VARIADIC_EXPAND_1(FUNC, X1, X2, X3, X4) \
>>>                             ^
>>> C:\Program Files (x86)\Microsoft Visual Studio
>>> 11.0\VC\include\xstddef:531:50: note: expanded from macro
>>> '_VARIADIC_EXPAND_1'
>>> #define _VARIADIC_EXPAND_1(FUNC, X1, X2, X3, X4) \
>>>                                                   ^
>>> C:\Program Files (x86)\Microsoft Visual Studio
>>> 11.0\VC\include\xrefwrap:152:2: note: expanded from macro
>>> '_CLASS_RESULT_OF_PF_OPT_0X'
>>>          _VARIADIC_CALL_OPT_X1(_CLASS_RESULT_OF_PF, \
>>>          ^
>>> _______________________________________________
>>> cfe-dev mailing list
>>> cfe-dev at cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
>



More information about the cfe-dev mailing list