如何在Visual Studio和stlib中使用clang?

时间:2015-08-06 11:29:11

标签: visual-studio clang visual-studio-2015 clang++ llvm-clang

我已经为windows 3.6.2和Visual Studio 2015安装了预构建的llvm + clang。现在在VS 2015中,您可以创建项目并将编译器设置为clang。似乎clang的安装已将编译器注册到设置中。其他一切都很好,除了我不能使用和标准库。

clang的编译器设置是属性 - >通用 - >平台工具

下的LLVM-vs2014

例如,在编译此代码时

#include <iostream>

int main(int argc, char ** argv) {
    return 0; }

如果删除#include行,一切正常。

任何想法?

The output message from VS is:
1>------ Build started: Project: TT, Configuration: Debug Win32 ------

1>clang-cl.exe : warning : argument unused during compilation: '/ZI'

1>clang-cl.exe : warning : argument unused during compilation: '/Gm'

1>clang-cl.exe : warning : argument unused during compilation: '/GS'

1>clang-cl.exe : warning : argument unused during compilation: '/fp:precise'

1>clang-cl.exe : warning : argument unused during compilation: '/FdDebug\vc140.pdb'

1>  In file included from main.cpp:1:

1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\iostream:6:

1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\istream:6:

1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\ostream:6:

1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\ios:6:

1

>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xlocnum:7:

    1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\cmath:656:

    1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xtgmath.h:8:

    1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xtr1common(231,22): error : use of undeclared identifier 'char16_t'

    1>          struct _Is_integral<char16_t>

    1>                              ^
    1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xtr1common(237,22): error : use of undeclared identifier 'char32_t'

    1>          struct _Is_integral<char32_t>

    1>                              ^
    1>  In file included from main.cpp:1:

    1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\iostream:6:

    1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\istream:6:

    1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\ostream:6:

    1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\ios:6:

    1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xlocnum:10:

    1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\streambuf:6:

    1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xiosbase:6:

    1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xlocale:8:

    1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\stdexcept:6:

    1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\exception:7:

    1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\type_traits:6:

    1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xstddef(408,14): error : use of undeclared identifier 'char16_t'

    1>          struct hash<char16_t>

    1>                      ^

    1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xstddef(414,14): error : use of undeclared identifier 'char32_t'

    1>          struct hash<char32_t>

    1>                      ^
    1>  In file included from main.cpp:1:

    1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\iostream:6:

    1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\istream:6:

    1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\ostream:6:

    1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\ios:6:

    1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xlocnum:10:
1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\streambuf:6:

        1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xiosbase:6:

        1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xlocale:8:

    1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\stdexcept:7:
    1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xstring:6:
    1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xmemory0:8:
    1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\limits(615,33): error : use of undeclared identifier 'char16_t'
    1>  template<> class numeric_limits<char16_t>

1>                                  ^
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\limits(905,33): error : use of undeclared identifier 'char32_t'
1>  template<> class numeric_limits<char32_t>
1>                                  ^
1>  In file included from main.cpp:1:
1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\iostream:6:
1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\istream:6:
1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\ostream:6:
1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\ios:6:
1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xlocnum:10:
1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\streambuf:6:
1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xiosbase:6:
1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xlocale:8:
1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\stdexcept:7:
1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xstring:6:
1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xmemory0:10:
1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xutility:8:
1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\utility:7:
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\iosfwd(267,21): error : use of undeclared identifier 'char16_t'
1>          struct char_traits<char16_t>
1>                             ^
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\iosfwd(276,21): error : use of undeclared identifier 'char32_t'
1>          struct char_traits<char32_t>
1>                             ^
1>  In file included from main.cpp:1:
1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\iostream:6:
1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\istream:6:
1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\ostream:6:
1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\ios:6:
1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xlocnum:10:
1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\streambuf:6:
1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xiosbase:6:
1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xlocale:8:
1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\stdexcept:7:
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xstring(2623,22): error : use of undeclared identifier 'char16_t'
1>  typedef basic_string<char16_t, char_traits<char16_t>, allocator<char16_t> >
1>                       ^
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xstring(2623,53): error : expected unqualified-id
1>  typedef basic_string<char16_t, char_traits<char16_t>, allocator<char16_t> >
1>                                                      ^
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xstring(2625,22): error : use of undeclared identifier 'char32_t'
1>  typedef basic_string<char32_t, char_traits<char32_t>, allocator<char32_t> >
1>                       ^
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xstring(2625,53): error : expected unqualified-id
1>  typedef basic_string<char32_t, char_traits<char32_t>, allocator<char32_t> >
1>                                                      ^
1>  In file included from main.cpp:1:
1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\iostream:6:
1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\istream:6:
1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\ostream:6:
1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\ios:6:
1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xlocnum:10:
1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\streambuf:6:
1>  In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xiosbase:6:
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xlocale(1004,30): error : use of undeclared identifier 'char16_t'
1>          class _CRTIMP2_PURE codecvt<char16_t, char, _Mbstatet>
1>                                      ^
1>C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xlocale(1328,30): error : use of undeclared identifier 'char32_t'
1>          class _CRTIMP2_PURE codecvt<char32_t, char, _Mbstatet>
1>                                      ^
1>  14 errors generated.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

1 个答案:

答案 0 :(得分:2)

Clang 3.6不支持Microsoft模式下的C ++ 11关键字char16_tchar32_tsee the source)。然而,根据LLVM网站的说法,3.7确实会在三周内(8月21日)发布。同时,您可以安装3.7 release candidatesnapshot build