Visual Studio编译std库中的错误

时间:2015-07-17 21:16:35

标签: c++ visual-c++ visual-studio-2015 folly

我正在尝试按照此处提供的说明松散地在Visual Studio 2015 RC中构建Facebook愚蠢: https://github.com/jbandela/folly/tree/vc11

我希望通过2015年扩展的C ++ 11支持,我可能比以前更容易。我一直在处理一个不错的剪辑问题,但我现在得到一组对我没有意义的编译错误。这是编译输出的顶部,第一个错误是:

2>------ Build started: Project: folly, Configuration: Debug Win32 ------
2>  pch.cpp
2>  Unknown compiler version - please run the configure tests and report the results
2>c:\program files (x86)\microsoft visual studio 14.0\vc\include\xstring(26): error C2143: syntax error: missing ',' before '<'
2>c:\program files (x86)\microsoft visual studio 14.0\vc\include\xstring(26): error C2143: syntax error: missing ',' before '<'

这是它带来的错误位置的来源,再次在std命名空间的xstring中:

template<class _Mystr>
class _String_const_iterator
    : public _Iterator012<random_access_iterator_tag, // <---- line 26
        typename _Mystr::value_type,
        typename _Mystr::difference_type,
        typename _Mystr::const_pointer,
        typename _Mystr::const_reference,
        _Iterator_base>
{

我得到的另一个错误示例:

 C2039  'exception': is not a member of 'std'   folly   c:\program files (x86)\microsoft visual studio 14.0\vc\include\stdexcept    27

来源:

class logic_error
    : public _XSTD exception
    {   

我对于std库本身如何产生这些和其他219错误感到困惑。我通常使用Linux / g ++构建,所以我不熟悉Visual Studio构建环境。我可能做了一些简单的错误。这样的错误可能是什么原因?

更新1

添加更多信息。我没有提升就重现了这一点,因此“未知的编译器版本”警告消失了。我还从编译中获得了更多输出:

     Microsoft (R) C/C++ Optimizing Compiler Version 19.00.22816 for x86
     Copyright (C) Microsoft Corporation.  All rights reserved.

     cl /c /I"C:\Users\myname\Documents\Visual Studio 2015\Projects\folly\folly\folly\folly" /I"C:\Users\myname\Documents\Visual Studio 2015\Projects\folly\folly\\" /I"Generated Files\\" /IDebug\ /ZI /ZW /ZW:nostdlib /W3 /WX- /sdl /MP /Od /Oy- /D _VARIADIC_MAX=10 /D FOLLY_NO_CONFIG /D _TIMESPEC_DEFINED /D FOLLY_HAVE_STD__IS_TRIVIALLY_COPYABLE /D _UNICODE /D UNICODE /D _DEBUG /D WINAPI_FAMILY=WINAPI_FAMILY_APP /D __WRL_NO_DEFAULT_LIB__ /Gm- /EHsc /RTC1 /MDd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Yc"pch.h" /Fp"Debug\folly.pch" /Fo"Debug\\" /Fd"Debug\vc140.pdb" /Gd /TP /wd4453 /wd28204 /FU"C:\Program Files (x86)\Microsoft SDKs\Windows Kits\10\ExtensionSDKs\Microsoft.VCLibs\14.0\References\CommonConfiguration\neutral\platform.winmd" /FU"C:\Program Files (x86)\Windows Kits\10\References\Windows.Foundation.FoundationContract\1.0.0.0\Windows.Foundation.FoundationContract.winmd" /FU"C:\Program Files (x86)\Windows Kits\10\References\Windows.Foundation.UniversalApiContract\1.0.0.0\Windows.Foundation.UniversalApiContract.winmd" /FU"C:\Program Files (x86)\Windows Kits\10\References\Windows.Networking.Connectivity.WwanContract\1.0.0.0\Windows.Networking.Connectivity.WwanContract.winmd" /analyze- /errorReport:prompt /bigobj pch.cpp

     pch.cpp
 1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\xstring(26): error C2143: syntax error: missing ',' before '<'
     c:\program files (x86)\microsoft visual studio 14.0\vc\include\xstring(266): note: see reference to class template instantiation 'std::_String_const_iterator<_Mystr>' being compiled
 1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\xstring(27): error C2518: keyword 'typename' illegal in base class list; ignored
 1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\xstring(28): error C2518: keyword 'typename' illegal in base class list; ignored
 1>c:\program files (x86)\microsoft visual studio 14.0\vc\include\xstring(29): error C2518: keyword 'typename' illegal in base class list; ignored
 ...

更新2

在启用和未启用预编译标头选项的情况下会发生这些错误。

2 个答案:

答案 0 :(得分:1)

此消息:

  

未知的编译器版本 - 请运行configure tests和report   结果

由一个boost头文件发出。 Boost需要VC ++的特定版本,在这种情况下11.0对应于VS 2012.这可能是您获得所有这些错误的原因。您必须下载Visual Studio 2012,然后按照您提到的链接中的说明进行操作。

答案 1 :(得分:0)

你确定标题dll是最新的吗?它们经常更新。 我在具有相同构建的多个系统上运行时遇到过这种情况。 另外一个检查是在库调用开始时添加std ::只是为了确保 - 这样你就可以轻松地测试天气它是dll还是你的拼写。

另外,请检查您是否收到'v120'或'v140'工具集错误,这表示您是否错误地使用了VS的版本。

另一种方法是将VC lib文件包含为本地“头”,至少确保编译器连接。

我希望有帮助