MSVC在未编译任何源的情况下因编译器错误而失败
MSVC fails with compiler errors without compiling any sources
所有源文件似乎都编译得很好。
然而,由于我做到了这一点,我得到了一个新的编译器错误:
1>------ Erstellen gestartet: Projekt: OpenLieroX, Konfiguration: Debug Win32 ------
1>Der Buildvorgang wurde am 29.03.2012 23:57:39 gestartet.
1>InitializeBuildStatus:
1> Aktualisieren des Timestamps von "DebugOpenLieroX.unsuccessfulbuild".
1>ClCompile:
1> Alle Ausgaben sind aktuell.
1> Alle Ausgaben sind aktuell.
1> Alle Ausgaben sind aktuell.
1> Alle Ausgaben sind aktuell.
1> Alle Ausgaben sind aktuell.
1> Alle Ausgaben sind aktuell.
1> Alle Ausgaben sind aktuell.
1> Alle Ausgaben sind aktuell.
1> Alle Ausgaben sind aktuell.
1> Alle Ausgaben sind aktuell.
1> Alle Ausgaben sind aktuell.
1> Alle Ausgaben sind aktuell.
1> Alle Ausgaben sind aktuell.
1> Alle Ausgaben sind aktuell.
1> Alle Ausgaben sind aktuell.
1> Alle Ausgaben sind aktuell.
1> Alle Ausgaben sind aktuell.
1> Alle Ausgaben sind aktuell.
1> Alle Ausgaben sind aktuell.
1> Alle Ausgaben sind aktuell.
1> Alle Ausgaben sind aktuell.
1> Alle Ausgaben sind aktuell.
1> Alle Ausgaben sind aktuell.
1> Alle Ausgaben sind aktuell.
1> Alle Ausgaben sind aktuell.
1> Alle Ausgaben sind aktuell.
1> Alle Ausgaben sind aktuell.
1>C:Program Files (x86)Microsoft Visual Studio 10.0VCincludestring.h(54): warning RC4011: identifier truncated to '_CRT_SECURE_CPP_OVERLOAD_STANDA'
1>
1>C:Program Files (x86)Microsoft Visual Studio 10.0VCincludestring.h(76): warning RC4011: identifier truncated to '_CRT_SECURE_CPP_OVERLOAD_SECURE'
1>
1>C:Program Files (x86)Microsoft Visual Studio 10.0VCincludeyvals.h(367): warning RC4011: identifier truncated to '_DISABLE_DEPRECATE_STATIC_CPPLI'
1>
1>C:Program Files (x86)boostboost_1_47boost/config/suffix.hpp(83): warning RC4011: identifier truncated to 'BOOST_NO_CV_VOID_SPECIALIZATION'
1>
1>C:Program Files (x86)boostboost_1_47boost/config/suffix.hpp(92): warning RC4011: identifier truncated to 'BOOST_NO_LIMITS_COMPILE_TIME_CO'
1>
1>C:Program Files (x86)boostboost_1_47boost/config/suffix.hpp(102): warning RC4011: identifier truncated to 'BOOST_NO_LONG_LONG_NUMERIC_LIMI'
1>
1>C:Program Files (x86)boostboost_1_47boost/config/suffix.hpp(117): warning RC4011: identifier truncated to 'BOOST_NO_MS_INT64_NUMERIC_LIMIT'
1>
1>C:Program Files (x86)boostboost_1_47boost/config/suffix.hpp(133): warning RC4011: identifier truncated to 'BOOST_NO_TEMPLATE_PARTIAL_SPECI'
1>
1>C:Program Files (x86)boostboost_1_47boost/config/suffix.hpp(134): warning RC4011: identifier truncated to 'BOOST_BCB_PARTIAL_SPECIALIZATIO'
1>
1>C:Program Files (x86)boostboost_1_47boost/config/suffix.hpp(141): warning RC4011: identifier truncated to 'BOOST_NO_TEMPLATE_PARTIAL_SPECI'
1>
1>C:Program Files (x86)boostboost_1_47boost/config/suffix.hpp(142): warning RC4011: identifier truncated to 'BOOST_NO_ARRAY_TYPE_SPECIALIZAT'
1>
1>C:Program Files (x86)boostboost_1_47boost/config/suffix.hpp(149): warning RC4011: identifier truncated to 'BOOST_NO_TEMPLATE_PARTIAL_SPECI'
1>
1>C:Program Files (x86)boostboost_1_47boost/config/suffix.hpp(158): warning RC4011: identifier truncated to 'BOOST_NO_TEMPLATE_PARTIAL_SPECI'
1>
1>C:Program Files (x86)boostboost_1_47boost/config/suffix.hpp(159): warning RC4011: identifier truncated to 'BOOST_NO_PARTIAL_SPECIALIZATION'
1>
1>C:Program Files (x86)boostboost_1_47boost/config/suffix.hpp(169): warning RC4011: identifier truncated to 'BOOST_NO_TEMPLATED_ITERATOR_CON'
1>
1>C:Program Files (x86)boostboost_1_47boost/config/suffix.hpp(186): warning RC4011: identifier truncated to 'BOOST_NO_ARGUMENT_DEPENDENT_LOO'
1>
1>C:Program Files (x86)boostboost_1_47boost/config/suffix.hpp(186): warning RC4011: identifier truncated to 'BOOST_FUNCTION_SCOPE_USING_DECL'
1>
1>C:Program Files (x86)boostboost_1_47boost/config/suffix.hpp(341): warning RC4011: identifier truncated to 'BOOST_NO_0X_HDR_INITIALIZER_LIS'
1>
1>C:Program Files (x86)boostboost_1_47boost/config/suffix.hpp(344): warning RC4011: identifier truncated to 'BOOST_NO_0X_HDR_INITIALIZER_LIS'
1>
1>C:Program Files (x86)boostboost_1_47boost/config/suffix.hpp(566): warning RC4011: identifier truncated to 'BOOST_NO_EXPLICIT_FUNCTION_TEMP'
1>
1>C:Program Files (x86)boostboost_1_47boost/limits.hpp(22): warning RC4011: identifier truncated to 'BOOST_NO_LONG_LONG_NUMERIC_LIMI'
1>
1>C:Program Files (x86)boostboost_1_47boost/limits.hpp(23): warning RC4011: identifier truncated to 'BOOST_NO_MS_INT64_NUMERIC_LIMIT'
1>
1>C:Program Files (x86)boostboost_1_47boost/cstdint.hpp(300): error RC2177: constant too big
1>
1>C:Program Files (x86)boostboost_1_47boost/cstdint.hpp(300): fatal error RC1012: mismatched parenthesis : missing '
1>
1>Fehler beim Erstellen
我真的不明白我为什么会这样。也不是来自什么源文件,因为它不再编译任何源文件(因为所有源文件都已成功编译)。
(从注释中重新排序,以便将问题标记为已回答。)
您不应该使用资源编译器编译普通代码。
虽然标记的答案在这里已经是正确的,但一些背景:MSVC资源编译器截断字符31处的宏名称。类似的问题也会出现在较新的系统头中,比如VC10或更高版本中的系统头,它们的宏名称定义超过31个字符。另见M$的回复,他们称这只是"设计",而不是修复他们的RC.EXE:
http://connect.microsoft.com/VisualStudio/feedback/details/532929/rc4011-warnings-from-vc10-rc
受影响的宏名称大于31个字符的系统头是因为VC10 string.h、tchar.h、wchar.h、yvals.h,可能还有更多。。。另请参阅:
http://social.msdn.microsoft.com/Forums/vstudio/en-US/ea289832-c48c-475b-a922-bf94d2ee54e4/vs2012-update-1-fatal-error-rc10056-in-c-project-when-v110xp-platform-is-chosen
当我试图使用Visual Studio 2013为Windows XP和POS Ready 2009进行编译时,遇到了类似的问题。应用程序使用Platform Toolset
配置属性中的标准Visual Studio 2013 (v120)
设置编译得很好,但当更改为Visual Studio 2013 - Windows XP (v120_xp)
以针对Windows XP时,我收到了一个编译错误:
>C:Program Files (x86)Microsoft SDKsWindowsv7.1Aincludewinsock2.h(2752): fatal error RC10056:
跳转到WinSock2.h include文件中的位置显示了一个使用__out_bcount_part_opt()
宏的函数原型。
看到这篇文章后,我意识到这个错误是资源编译器的错误。进一步看,我发现源代码和资源文件中都包含的头文件piflocal.h
包含WinSock2.h
头文件。
换句话说,应用程序源代码有一个头文件piflocal.h
,它包含资源文件pif.rc
使用的头文件resource.h
以及C源文件所需的定义。piflocal.h
中的一些定义需要来自Microsoft标准头文件WinSock2.h
的定义,因此WinSock2.h
文件被#包含在piflocal.h
中,使其可用。然而,当资源编译器作为引入各种头文件的一部分,试图处理WinSock2.h
文件作为处理piflocal.h
的一部分时,它遇到了__out_bcount_part_opt()
宏并失败了。
顺便说一句,__out_bcount_part_opt()
宏是Windows标头中使用的标头注释的一部分。
标头注释描述函数如何使用其参数和返回值。这些注释已添加到许多Windows头文件,以帮助您确保正在调用Windows API正确地如果启用代码分析,则可从使用Visual Studio 2005,编译器将生成6000级如果您没有按照使用情况调用这些函数,则会发出警告通过注释描述。您也可以添加这些注释在您自己的代码中,以确保正确调用它。到在Visual Studio中启用代码分析,请参阅Visual Studio版本。
这些注释在Specstrings.h中定义。它们基于作为标准注释语言(SAL)一部分的基元,以及使用declspec("SAL*")实现。
然后,我对resource.h
和piflocal.h
头文件进行了必要的源代码更改,使得pif.rc
从piflocal.h
所需的定义很少移动到resource.h
中,并且在编译pif.rc
时,资源编译器不再包含或拉入头文件piflocal.h
。
通过从资源编译器引入的头文件列表中删除WinSock2.h
,错误不再发生。
我不知道为什么这是用标准的Visual Studio 2013设置编译的,但在针对Windows XP及其变体时失败了。
结论:如果遇到此错误或类似错误,则很可能在资源编译器中包含一个头文件,该头文件的宏定义与资源编译器不兼容。
- MSVC多行宏编译器错误
- 静态数据成员的问题-修复链接错误会导致编译器错误
- C++,我收到一个无法理解的编译器错误
- 我收到同义重复编译器错误。我应该如何修复"类型"X"的参数与类型"X"的参数不兼容?
- 重载方法的方式会在使用临时调用时生成编译器错误
- 尝试使用继承和模板实现CRTP.Visual Studio正在生成编译器错误
- 编译器错误:destuctor 的更宽松的抛出说明符
- Android NDK clang 编译器错误在 Windows 上显示'No such file or directory'
- C++ G++ 编译器 - 错误:隐式声明的定义
- 这个失败的测试是将零添加到空指针未定义的行为、编译器错误还是其他什么?
- 模板模板参数和模板别名:编译器错误?
- C++ 编译器错误:P1LinkedList.cpp:145:错误:重载的"to_string(int&)"调用不明确
- 在gcc中意外调用了Const重载.编译器错误或兼容性修复程序
- C1001内部编译器错误是由于矢量初始化(如数组)引起的
- 编译器错误(英特尔并行工作室 2019 与 Visual Studio 社区 2019)
- 如何在C++中克服此 C4430 编译器错误?
- 尝试使用 WinBGI 显示文本时出现编译器错误
- 使用typedef'ed返回类型声明友元函数时出现编译器错误
- 如何在类模板的成员函数中正确调用函数对象?正在生成 Visual Studio 编译器错误 C2440
- C++自定义分配器大小参数作为模板参数会引发编译器错误