Search code examples
c++visual-studiostlllvmllvm-clang

Can I use GCC's / LLVM's STL headers with VS?


I am using MSVC++ 2013, and I installed the Clang plugin.

However, since I'm using STL, I'm getting bugs like this one:

In file included from C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\map:6:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include\xtree(1667,3) :  error: cannot compile this try statement yet
            _TRY_BEGIN
            ^~~~~~~~~~

actual code

They are quite a lot. In fact, there's only problems on the header files -- and it's what has me confused.

Is this an actual compiler bug? Incompatibility with MS' STL implementation?

If so, can I fix it, and how?

I thought of using GCC's or LLVM's headers, but I don't know how -- any pointers would be greatly appreciated.


Solution

  • Since you insist the environment is set up right, I looked up that exact macro that's not understood. That particular error can occur when the MSVC headers themselves include xstddef when _HAS_EXCEPTIONS is defined as 0. I can't find any other conditions on that macro, so it appears that your clang is compiling without exceptions.

    This rings a bell in my head, and Clang had problems with exceptions for a long time on windows. Occording to this link, it still does in MSVC compatability mode: "Exceptions and SEH: Minimal. Clang can parse both constructs, but does not know how to emit compatible handlers. Clang cannot throw exceptions but it can rethrow them." http://clang.llvm.org/docs/MSVCCompatibility.html