0

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.

rev
  • 1,861
  • 17
  • 27
  • 1
    All standard libraries use compiler-specific extensions to work. Clang doesn't understand the MSVC extensions, nor would MSVC be able to use gcc/clang libraries. clang and gcc try to have the same extensions, so they can use the same libraries. You'll have to tell the extension to use GCC/clang compatible headers, but I don't know how. – Mooing Duck Jan 31 '15 at 01:06
  • @MooingDuck well, I'm using `clang-cl.exe` -- isn't it exactly made for this? – rev Jan 31 '15 at 01:08
  • Did not know about that feature. http://clang.llvm.org/docs/UsersManual.html#clang-cl says "it should be executed inside a Visual Studio Native Tools Command Prompt or a regular Command Prompt where the environment has been set up using e.g. vcvars32.bat", is that being done? – Mooing Duck Feb 02 '15 at 17:27
  • @MooingDuck it is, but it fails to compile MSVC's headers -- which is why I'm unable to compile my project – rev Feb 02 '15 at 17:28

2 Answers2

1

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

Mooing Duck
  • 64,318
  • 19
  • 100
  • 158
0

I don't think llvm's libc++ can be compiled with msvc. Your best bet would be to try to use LLVM to produce MSVC compatible code that can (in theory) be linked with Visual C++ compiled code.

http://clang.llvm.org/docs/MSVCCompatibility.html