1

Why does clang++ compile this:

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char **argv) {
    printf("Hello World!\n");
    return EXIT_SUCCESS;
}

and do not want compile this:

#include <iostream>
int main()
{
    std::cout << "FFFF\n";
    return 0;
}
???

command line:

clang++ -c hello.cpp -emit-llvm -o hello.bc

too many errors emitted like this:

C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\xrefwrap:222:22:
note:
      expanded from macro '_CLASS_RESULT_OF_PMF_OPT_0X'
                        __thiscall, X2, X3, X4)

Windows 7 64, clang-3.2, llvm-3.2, VS2012


=====UPDATE=====

Command line (with -v):

clang++ -c hello.cpp -emit-llvm -o hello.bc -v

What I get:

clang version 3.2 (tags/RELEASE_32/final)
Target: i686-pc-win32
Thread model: posix
 "C:/llvm/clang/build/bin/Debug/clang++.exe" -cc1 -triple i686-pc-win32 -emit-ll
vm-bc -disable-free -main-file-name 321.cpp -mrelocation-model static -mdisable-
fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -target-cpu pentium4 -m
omit-leaf-frame-pointer -v -coverage-file "C:\llvm\3211.bc" -resource-dir "C:/
llvm/clang/build/bin/Debug\..\lib\clang\3.2" -fmodule-cache-path "C:\Users\
\kpdev\AppData\Local\Temp\clang-module-cache" -internal-isystem C:/llvm/clan
g/build/bin/Debug/../lib/clang/3.2/include -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 -ferro
r-limit 3 -fmessage-length 80 -mstackrealign -fms-extensions -fms-compatibility
-fmsc-version=1300 -fdelayed-template-parsing -fobjc-runtime=gcc -fobjc-default-
synthesize-properties -fcxx-exceptions -fexceptions -fdiagnostics-show-option -f
color-diagnostics -o "C:\llvm\3211.bc" -x c++ "C:\llvm\321.cpp"
clang -cc1 version 3.2 based upon LLVM 3.2svn default target i686-pc-win32
    #include "..." search starts here:
    #include <...>search starts here:
 C:/llvm/clang/build/bin/Debug/../lib/clang/3.2/include
 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 C:\llvm\321.cpp:1:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\inc
lude\iostream:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\inc
lude\istream:6:
...etc.

and then:

C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\type_traits:1072:
33: error:
      '_Ty' does not refer to a value
                _HAS_TRIVIAL_MOVE_CONSTRUCTOR(_Ty)
                                              ^
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\type_traits:52:38
: note:
      expanded from macro '_HAS_TRIVIAL_MOVE_CONSTRUCTOR'
                        && __has_trivial_move_constructor(_Ty)>
                                                          ^
...etc.

So... -internal-isystem point to wrong path. How to change it ?

1 Answer 1

1

You have the include path configured incorrectly for clang. This:

C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\xrefwrap

is a header file from the VS 2012 installation and has noting to do with clang (and is apparently incompatible with it).

Make sure your environment isn't set up for the VC++ compile. For example, make sure there's no INCLUDE environment variable that's set up for VC++. There may be other env variables to make sure aren't inappropriately set for clang, too, such as LIB.

Sign up to request clarification or add additional context in comments.

3 Comments

Thank you. But I cant find this environment variable. Where is it hide?
So if you do set INCLUDE from the command line does it say Environment variable INCLUDE not defined or something else? If you're building from the command line (and not an IDE or something) using that command and there's no INCLUDE environment variable then I'm not sure why clang would be searching C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE. But I don't have clang installed on my Windows machine, so I can't try it out or test at the moment. You might see if the -v option gives you any helpful information.
If I do set INCLUDE (or set LIB), it say variables not defined. Rezult of -v option in question update.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.