gpt4 book ai didi

c++ - '标识符' : redefinition errors ( error C2011 & error C2370)

转载 作者:太空狗 更新时间:2023-10-29 23:41:28 31 4
gpt4 key购买 nike

每次我尝试编译我的代码时,我都会遇到大量错误。这不是我的代码的问题,因为它在另一台计算机上工作得很好。我尝试重新安装和修复,但这没有帮助。这是整个错误消息:

1>------ Build started: Project: Raptor Triangle 2, Configuration: Debug Win32 ------
1> Raptor Triangle 2.cpp
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(57): error C2011: 'vc_attributes::YesNoMaybe' : 'enum' type redefinition
1> c:\program files\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(57) : see declaration of 'vc_attributes::YesNoMaybe'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(67): error C2011: 'vc_attributes::AccessType' : 'enum' type redefinition
1> c:\program files\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(67) : see declaration of 'vc_attributes::AccessType'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(81): error C2011: 'vc_attributes::Pre' : 'struct' type redefinition
1> c:\program files\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(81) : see declaration of 'vc_attributes::Pre'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(78): error C3094: 'repeatable': anonymous usage not allowed
1> e:\programs\c++\raptor triangle 2\raptor triangle 2\predefined c++ attributes (compiler internal)(147) : see declaration of 'repeatable'
1> attribute can only be applied to: 'class', 'struct'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(112): error C2011: 'vc_attributes::Post' : 'struct' type redefinition
1> c:\program files\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(112) : see declaration of 'vc_attributes::Post'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(109): error C3094: 'repeatable': anonymous usage not allowed
1> e:\programs\c++\raptor triangle 2\raptor triangle 2\predefined c++ attributes (compiler internal)(147) : see declaration of 'repeatable'
1> attribute can only be applied to: 'class', 'struct'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(143): error C2011: 'vc_attributes::FormatString' : 'struct' type redefinition
1> c:\program files\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(143) : see declaration of 'vc_attributes::FormatString'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(155): error C2011: 'vc_attributes::InvalidCheck' : 'struct' type redefinition
1> c:\program files\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(155) : see declaration of 'vc_attributes::InvalidCheck'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(152): error C3094: 'repeatable': anonymous usage not allowed
1> e:\programs\c++\raptor triangle 2\raptor triangle 2\predefined c++ attributes (compiler internal)(147) : see declaration of 'repeatable'
1> attribute can only be applied to: 'class', 'struct'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(165): error C2011: 'vc_attributes::Success' : 'struct' type redefinition
1> c:\program files\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(165) : see declaration of 'vc_attributes::Success'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(176): error C2011: 'vc_attributes::PreBound' : 'struct' type redefinition
1> c:\program files\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(176) : see declaration of 'vc_attributes::PreBound'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(173): error C3094: 'repeatable': anonymous usage not allowed
1> e:\programs\c++\raptor triangle 2\raptor triangle 2\predefined c++ attributes (compiler internal)(147) : see declaration of 'repeatable'
1> attribute can only be applied to: 'class', 'struct'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(186): error C2011: 'vc_attributes::PostBound' : 'struct' type redefinition
1> c:\program files\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(186) : see declaration of 'vc_attributes::PostBound'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(183): error C3094: 'repeatable': anonymous usage not allowed
1> e:\programs\c++\raptor triangle 2\raptor triangle 2\predefined c++ attributes (compiler internal)(147) : see declaration of 'repeatable'
1> attribute can only be applied to: 'class', 'struct'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(196): error C2011: 'vc_attributes::PreRange' : 'struct' type redefinition
1> c:\program files\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(196) : see declaration of 'vc_attributes::PreRange'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(193): error C3094: 'repeatable': anonymous usage not allowed
1> e:\programs\c++\raptor triangle 2\raptor triangle 2\predefined c++ attributes (compiler internal)(147) : see declaration of 'repeatable'
1> attribute can only be applied to: 'class', 'struct'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(208): error C2011: 'vc_attributes::PostRange' : 'struct' type redefinition
1> c:\program files\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(208) : see declaration of 'vc_attributes::PostRange'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(205): error C3094: 'repeatable': anonymous usage not allowed
1> e:\programs\c++\raptor triangle 2\raptor triangle 2\predefined c++ attributes (compiler internal)(147) : see declaration of 'repeatable'
1> attribute can only be applied to: 'class', 'struct'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(245): error C2370: 'SA_Yes' : redefinition; different storage class
1> c:\program files\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(245) : see declaration of 'SA_Yes'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(246): error C2370: 'SA_No' : redefinition; different storage class
1> c:\program files\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(246) : see declaration of 'SA_No'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(247): error C2370: 'SA_Maybe' : redefinition; different storage class
1> c:\program files\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(247) : see declaration of 'SA_Maybe'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(250): error C2370: 'SA_NoAccess' : redefinition; different storage class
1> c:\program files\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(250) : see declaration of 'SA_NoAccess'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(251): error C2370: 'SA_Read' : redefinition; different storage class
1> c:\program files\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(251) : see declaration of 'SA_Read'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(252): error C2370: 'SA_Write' : redefinition; different storage class
1> c:\program files\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(252) : see declaration of 'SA_Write'
1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(253): error C2370: 'SA_ReadWrite' : redefinition; different storage class
1> c:\program files\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(253) : see declaration of 'SA_ReadWrite'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

帮助?哈哈。我不明白。我查看了错误代码,但不知道该怎么做。

此外,如果需要,我可以发布代码,但它很长。

编辑:我解决了它,但我不明白为什么。我去掉了包含 windows.h 的行,这是 Sleep() 所需要的。我仍然不明白为什么这很重要。

最佳答案

C2370 的另一个原因是存在包含常量的头文件的多个拷贝。

不同的项目然后访问同一头文件的不同拷贝,破坏“#pragma once”并导致“C2370 重新定义;不同的存储类别”。

存在文件重复的一个常见原因是,当开发人员制作依赖库 header 的本地拷贝,而仍然存在全局可访问的 SDK。

关于c++ - '标识符' : redefinition errors ( error C2011 & error C2370),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10776593/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com