简体   繁体   English

MSVC在编译错误时失败而不编译任何源

[英]MSVC fails with compiler errors without compiling any sources

All source files seem to have compiled fine. 所有源文件似乎编译得很好。

However, since I achieved that, I am getting a new compiler error: 但是,由于我实现了这一点,我得到一个新的编译器错误:

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

I don't really understand why I get that. 我真的不明白为什么我会这样做。 And also not from what source file because it isn't compiling any sources anymore (because all have been compiled successfully). 而且不是来自什么源文件,因为它不再编译任何源(因为所有源文件都已成功编译)。

(Reposting from comment so question can be marked answered.) (重新发布评论,因此问题可以标记为已回答。)

You shouldn't be compiling normal code with the resource compiler. 您不应该使用资源编译器编译普通代码。

While the marked answer is already correct here some background: The MSVC Resource Compiler truncates macro names at char 31. Similar problems occur also with newer system headers like those from VC10 or later which have macro names defined with more than 31 chars. 虽然标记的答案在这里已经是正确的一些背景:MSVC资源编译器在char 31处截断宏名称。类似的问题也出现在较新的系统头文件中,例如来自VC10或更高版本的宏名称定义有超过31个字符的宏名称。 See also M$'s reply who call this simply 'by design' instead of fixing their RC.EXE: 另请参阅M $的回复,他们简单地称之为“按设计”,而不是修复他们的RC.EXE:

http://connect.microsoft.com/VisualStudio/feedback/details/532929/rc4011-warnings-from-vc10-rc http://connect.microsoft.com/VisualStudio/feedback/details/532929/rc4011-warnings-from-vc10-rc

Affected system headers with macro names greater than 31 chars are since VC10 string.h, tchar.h, wchar.h, yvals.h and probably some more ... see also: 宏名称大于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 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平台-IS-选择

When attempting to use Visual Studio 2013 to compile for Windows XP and POS Ready 2009 as a target, I ran into a similar problem. 当尝试使用Visual Studio 2013编译Windows XP和POS Ready 2009作为目标时,我遇到了类似的问题。 The application compiled fine with the standard Visual Studio 2013 (v120) setting in the Platform Toolset Configuration Properties however when changed to Visual Studio 2013 - Windows XP (v120_xp) to target Windows XP, I received a compilation error of: 使用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:

Jumping to the location in the WinSock2.h include file showed a function prototype which used the __out_bcount_part_opt() macro. 跳转到WinSock2.h包含文件中的位置显示了一个使用__out_bcount_part_opt()宏的函数原型。

After seeing this posting I realized that the error was a resource compiler error. 看到这个帖子后,我意识到错误是资源编译器错误。 Looking further what I discovered was that a header file, piflocal.h , that was included in both the source code and the resource file contained an include of the WinSock2.h header file. 进一步查看我发现的是源代码和资源文件中包含的头文件piflocal.h包含WinSock2.h头文件的包含。

In other words the application source code had a header file, piflocal.h , which contained defines needed by the header file resource.h used by the resource file pif.rc as well as the C source files. 换句话说,应用程序源代码有一个头文件piflocal.h ,它包含资源文件pif.rc使用的头文件resource.h所需的定义以及C源文件。 Some of the definitions in piflocal.h required definitions from the Microsoft standard header file WinSock2.h so the WinSock2.h file was #included into piflocal.h making it available. piflocal.h一些定义需要Microsoft标准头文件WinSock2.h中的定义,因此WinSock2.h文件#included到piflocal.h使其可用。 However when the resource compiler, as part of pulling in the various header files, attempted to process the WinSock2.h file as a part of processing piflocal.h , it ran into the __out_bcount_part_opt() macro and failed. 但是,当资源编译器作为拉入各种头文件的一部分,尝试将WinSock2.h文件作为处理piflocal.h的一部分进行处理piflocal.h ,它会遇到__out_bcount_part_opt()宏而失败。

The __out_bcount_part_opt() macro, by the way, is part of the Header Annotations used in Windows headers . 顺便说一句, __out_bcount_part_opt()宏是Windows标头中使用标头注释的一部分。

Header annotations describe how a function uses its parameters and return value. 标题注释描述函数如何使用其参数和返回值。 These annotations have been added to many of the Windows header files to help you ensure that you are calling the Windows API correctly. 这些注释已添加到许多Windows头文件中,以帮助您确保正确调用Windows API。 If you enable code analysis, which is available starting with the Visual Studio 2005, the compiler will produce level 6000 warnings if you are not calling these functions per the usage described through the annotations. 如果启用从Visual Studio 2005开始提供的代码分析,则如果不按照注释描述的用法调用这些函数,则编译器将生成6000级警告。 You can also add these annotations in your own code to ensure that it is being called correctly. 您还可以在自己的代码中添加这些注释,以确保正确调用它们。 To enable code analysis in Visual Studio, see the documentation for your version of Visual Studio. 若要在Visual Studio中启用代码分析,请参阅适用于您的Visual Studio版本的文档。

These annotations are defined in Specstrings.h. 这些注释在Specstrings.h中定义。 They are built on primitives that are part of the Standard Annotation Language (SAL) and implemented using declspec("SAL *"). 它们构建在原语上,这些原语是标准注释语言(SAL)的一部分,并使用declspec(“SAL *”)实现。

I then made the necessary source code changes to the resource.h and the piflocal.h header files so that few defines needed by pif.rc from piflocal.h were moved into resource.h and the header file piflocal.h was no longer included or pulled in by the resource compiler when compiling pif.rc . 然后我作了必要的源代码改变为resource.hpiflocal.h头文件,使得由需要一些定义pif.rcpiflocal.h移入resource.h和头文件piflocal.h不再纳入或者在编译pif.rc时由资源编译器拉pif.rc

By removing WinSock2.h from the list of header files pulled in by the resource compiler, the error no longer happened. 通过从资源编译器提取的头文件列表中删除WinSock2.h ,不再发生错误。

I do not know why this compiled with the standard Visual Studio 2013 settings and failed with targeting Windows XP and its variants. 我不知道为什么这会使用标准的Visual Studio 2013设置进行编译,并且无法定位Windows XP及其变体。

Conclusion: if you are running into this error or similar error, more than likely you are including into the resource compiler a header file with a macro definition which is incompatible with the resource compiler. 结论:如果遇到此错误或类似错误,您很可能会在资源编译器中包含一个带有宏定义的头文件,该文件与资源编译器不兼容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM