【问题标题】:MSVC fails with compiler errors without compiling any sourcesMSVC 在不编译任何源的情况下因编译器错误而失败
【发布时间】:2012-04-13 14:55:35
【问题描述】:

所有源文件似乎都编译得很好。

但是,自从我实现了这一点,我得到了一个新的编译器错误:

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 "Debug\OpenLieroX.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.0\VC\include\string.h(54): warning RC4011: identifier truncated to '_CRT_SECURE_CPP_OVERLOAD_STANDA'
1>  
1>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\string.h(76): warning RC4011: identifier truncated to '_CRT_SECURE_CPP_OVERLOAD_SECURE'
1>  
1>C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\yvals.h(367): warning RC4011: identifier truncated to '_DISABLE_DEPRECATE_STATIC_CPPLI'
1>  
1>C:\Program Files (x86)\boost\boost_1_47\boost/config/suffix.hpp(83): warning RC4011: identifier truncated to 'BOOST_NO_CV_VOID_SPECIALIZATION'
1>  
1>C:\Program Files (x86)\boost\boost_1_47\boost/config/suffix.hpp(92): warning RC4011: identifier truncated to 'BOOST_NO_LIMITS_COMPILE_TIME_CO'
1>  
1>C:\Program Files (x86)\boost\boost_1_47\boost/config/suffix.hpp(102): warning RC4011: identifier truncated to 'BOOST_NO_LONG_LONG_NUMERIC_LIMI'
1>  
1>C:\Program Files (x86)\boost\boost_1_47\boost/config/suffix.hpp(117): warning RC4011: identifier truncated to 'BOOST_NO_MS_INT64_NUMERIC_LIMIT'
1>  
1>C:\Program Files (x86)\boost\boost_1_47\boost/config/suffix.hpp(133): warning RC4011: identifier truncated to 'BOOST_NO_TEMPLATE_PARTIAL_SPECI'
1>  
1>C:\Program Files (x86)\boost\boost_1_47\boost/config/suffix.hpp(134): warning RC4011: identifier truncated to 'BOOST_BCB_PARTIAL_SPECIALIZATIO'
1>  
1>C:\Program Files (x86)\boost\boost_1_47\boost/config/suffix.hpp(141): warning RC4011: identifier truncated to 'BOOST_NO_TEMPLATE_PARTIAL_SPECI'
1>  
1>C:\Program Files (x86)\boost\boost_1_47\boost/config/suffix.hpp(142): warning RC4011: identifier truncated to 'BOOST_NO_ARRAY_TYPE_SPECIALIZAT'
1>  
1>C:\Program Files (x86)\boost\boost_1_47\boost/config/suffix.hpp(149): warning RC4011: identifier truncated to 'BOOST_NO_TEMPLATE_PARTIAL_SPECI'
1>  
1>C:\Program Files (x86)\boost\boost_1_47\boost/config/suffix.hpp(158): warning RC4011: identifier truncated to 'BOOST_NO_TEMPLATE_PARTIAL_SPECI'
1>  
1>C:\Program Files (x86)\boost\boost_1_47\boost/config/suffix.hpp(159): warning RC4011: identifier truncated to 'BOOST_NO_PARTIAL_SPECIALIZATION'
1>  
1>C:\Program Files (x86)\boost\boost_1_47\boost/config/suffix.hpp(169): warning RC4011: identifier truncated to 'BOOST_NO_TEMPLATED_ITERATOR_CON'
1>  
1>C:\Program Files (x86)\boost\boost_1_47\boost/config/suffix.hpp(186): warning RC4011: identifier truncated to 'BOOST_NO_ARGUMENT_DEPENDENT_LOO'
1>  
1>C:\Program Files (x86)\boost\boost_1_47\boost/config/suffix.hpp(186): warning RC4011: identifier truncated to 'BOOST_FUNCTION_SCOPE_USING_DECL'
1>  
1>C:\Program Files (x86)\boost\boost_1_47\boost/config/suffix.hpp(341): warning RC4011: identifier truncated to 'BOOST_NO_0X_HDR_INITIALIZER_LIS'
1>  
1>C:\Program Files (x86)\boost\boost_1_47\boost/config/suffix.hpp(344): warning RC4011: identifier truncated to 'BOOST_NO_0X_HDR_INITIALIZER_LIS'
1>  
1>C:\Program Files (x86)\boost\boost_1_47\boost/config/suffix.hpp(566): warning RC4011: identifier truncated to 'BOOST_NO_EXPLICIT_FUNCTION_TEMP'
1>  
1>C:\Program Files (x86)\boost\boost_1_47\boost/limits.hpp(22): warning RC4011: identifier truncated to 'BOOST_NO_LONG_LONG_NUMERIC_LIMI'
1>  
1>C:\Program Files (x86)\boost\boost_1_47\boost/limits.hpp(23): warning RC4011: identifier truncated to 'BOOST_NO_MS_INT64_NUMERIC_LIMIT'
1>  
1>C:\Program Files (x86)\boost\boost_1_47\boost/cstdint.hpp(300): error RC2177: constant too big
1>  
1>C:\Program Files (x86)\boost\boost_1_47\boost/cstdint.hpp(300): fatal error RC1012: mismatched parenthesis : missing '
1>
1>Fehler beim Erstellen

我真的不明白为什么会这样。而且也不是来自哪个源文件,因为它不再编译任何源(因为所有源都已成功编译)。

【问题讨论】:

  • 为什么要用资源编译器编译普通代码?
  • 您在编译的 RC 文件中直接包含了哪些头文件?
  • @ildjarn:感谢有关资源编译器的提示。就是这样。 (它包括一些其他源文件来获取版本宏常量。)(你应该把它变成一个真正的答案......)

标签: c++ visual-studio visual-studio-2010 visual-c++ visual-c++-2010


【解决方案1】:

(从评论中重新发布,以便可以将问题标记为已回答。)

您不应该使用资源编译器编译普通代码。

【讨论】:

    【解决方案2】:

    虽然标记的答案在这里已经是正确的一些背景: 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

    【讨论】:

    • 有没有办法手动纠正这个问题?编译 BLAT(开源)我得到“wchar.h(1018):致命错误 RC10056”错误。有什么解决办法吗?
    【解决方案3】:

    在尝试使用 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 SDKs\Windows\v7.1A\include\winsock2.h(2752): fatal error RC10056:
    

    跳转到 WinSock2.h 包含文件中的位置显示了一个使用 __out_bcount_part_opt() 宏的函数原型。

    看到这个帖子后,我意识到这个错误是资源编译器错误。进一步看,我发现源代码和资源文件中都包含一个头文件piflocal.h,其中包含WinSock2.h 头文件。

    换句话说,应用程序源代码有一个头文件piflocal.h,其中包含资源文件pif.rc 使用的头文件resource.h 以及C 源文件所需的定义。 piflocal.h 中的一些定义需要来自 Microsoft 标准头文件 WinSock2.h 的定义,因此 WinSock2.h 文件 #included 到 piflocal.h 中使其可用。然而,当资源编译器作为拉入各种头文件的一部分,尝试将WinSock2.h 文件作为处理piflocal.h 的一部分时,它遇到了__out_bcount_part_opt() 宏并且失败了。

    顺便说一下,__out_bcount_part_opt() 宏是 Header Annotations used in Windows headers 的一部分。

    标头注释描述了一个函数如何使用它的参数和 返回值。这些注释已添加到许多 Windows 头文件,以帮助您确保您正在调用 Windows API 正确。如果您启用代码分析,它可以从开始 使用 Visual Studio 2005,编译器将生成级别 6000 如果您没有根据用法调用这些函数,则会发出警告 通过注释进行描述。您还可以添加这些注释 在您自己的代码中以确保正确调用它。到 在 Visual Studio 中启用代码分析,请参阅您的文档 Visual Studio 版本。

    这些注释在 Specstrings.h 中定义。它们建立在 作为标准注释语言 (SAL) 一部分的原语和 使用 declspec("SAL*") 实现。

    然后,我对 resource.hpiflocal.h 头文件进行了必要的源代码更改,以便将 pif.rc 所需的少量定义从 piflocal.h 移到 resource.h 和头文件 piflocal.h 中编译pif.rc时不再被资源编译器包含或拉入。

    通过从资源编译器拉入的头文件列表中删除WinSock2.h,错误不再发生。

    我不知道为什么它使用标准的 Visual Studio 2013 设置进行编译,而无法针对 Windows XP 及其变体。

    结论:如果您遇到此错误或类似错误,则很可能您在资源编译器中包含了一个带有与资源编译器不兼容的宏定义的头文件。 p>

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-02-08
      • 2020-05-12
      • 2021-07-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-10-18
      • 2020-05-21
      相关资源
      最近更新 更多