C++ program not compiling with Clang and visual St

2019-03-16 18:13发布

问题:

I'm trying to compile the source code as described in this tutorial with visual c++ 2010 express. http://kevinaboos.wordpress.com/2013/07/23/clang-tutorial-part-ii-libtooling-example/

The full source code is over here. https://github.com/kevinaboos/LibToolingExample

I have used the executable provided in this link to install LLVM. I can't post the complete error message due to formatting issues. But I will try to give as much information as I can. When I'm trying to build the solution , I get the following errors :-

argument unused during compilation warnings.
C:\Program Files (x86)\LLVM\include\llvm/Support/Compiler.h(57,1): error : LLVM requires at least MSVC 2012.
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xlocnum(228,53): error : definition of dllimport static field not allowed
C:\Program Files (x86)\LLVM\include\llvm/ADT/IntrusiveRefCntPtr.h(26,9): fatal error : 'atomic' file not found

I'm using windows-7 64 bit. I've linked the header files and libraries by changing the project properties. I'm new to building c++ applications. Please help.

回答1:

For MSVC 2012 build error, found a solution here

According to Clang documentation, Exceptions and SEH are not supported yet. You have to disable it.

To disable exception in Visual Studio, please open Project Properties and go to C/C++, Preprocessor, then add _HAS_EXCEPTIONS=0 to Preprocessor Definitions.