gpt4 book ai didi

c++ STL __declspec(noreturn) 无效编译错误

转载 作者:行者123 更新时间:2023-11-28 08:17:28 25 4
gpt4 key购买 nike

我在编译 native C++ dll(在 VS2008 SP1 上)时出现编译错误。

错误是:

error C2062: type 'void' unexpected        c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\functional

“功能”中的行是:

 _CRTIMP2_PURE __declspec(noreturn) void __CLRCALL_PURE_OR_CDECL _Xfunc();

奇怪的是,在我为VS2008安装team explorer之前并没有出现这个错误。

我在VC++2010编译时也发现了类似的问题:

C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\vector(1425): error C2062: type 'void' unexpected.

“vector ”中的行是:

__declspec(noreturn) void _Xlen() const

你知道微软是否改变了一些语法规则吗?我玩了很多 vcproj 属性,但一点帮助也没有。

谢谢!

我的 .vcproj 文件(按要求):

<?xml version="1.0" encoding="windows-1255"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="ProjectNamespace"
ProjectGUID="{C5FA75AB-0476-46A5-AAF6-1A7D03E90763}"
RootNamespace="ProjectName"
SccProjectName="SAK"
SccAuxPath="SAK"
SccLocalPath="SAK"
SccProvider="SAK"
Keyword="ManagedCProj"
TargetFrameworkVersion="196613"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\Debug"
IntermediateDirectory=".\Debug"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="1"
CharacterSet="1"
ManagedExtensions="0"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="WIN32;_DEBUG;_USRDLL;ProjectName_EXPORTS;_USE_32BIT_TIME_T"
MinimalRebuild="false"
ExceptionHandling="1"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="1"
PrecompiledHeaderFile=".\Debug/ProjectName.pch"
AssemblerListingLocation=".\Debug/"
ObjectFile=".\Debug/"
ProgramDataBaseFileName=".\Debug/"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
IgnoreImportLibrary="false"
AdditionalDependencies="ws2_32.lib Mswsock.lib Advapi32.lib"
OutputFile="Debug\ProjectName.dll"
LinkIncremental="2"
SuppressStartupBanner="true"
AdditionalLibraryDirectories=""
ManifestFile="$(IntDir)\$(TargetFileName).intermediate.manifest"
IgnoreAllDefaultLibraries="false"
ModuleDefinitionFile=".\ProjectName.def"
GenerateDebugInformation="true"
AssemblyDebug="0"
ProgramDatabaseFile=".\Debug/ProjectName.pdb"
RandomizedBaseAddress="1"
FixedBaseAddress="0"
DataExecutionPrevention="0"
ImportLibrary=".\Debug/ProjectName.lib"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="0"
ManagedExtensions="0"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;NDEBUG;_USE_32BIT_TIME_T"
ExceptionHandling="0"
RuntimeLibrary="2"
UsePrecompiledHeader="2"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="ws2_32.lib Mswsock.lib Advapi32.lib"
LinkIncremental="1"
ModuleDefinitionFile=".\ProjectName.def"
GenerateDebugInformation="true"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
<AssemblyReference
RelativePath="System.dll"
AssemblyName="System, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"
MinFrameworkVersion="131072"
/>
<AssemblyReference
RelativePath="System.Data.dll"
AssemblyName="System.Data, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=x86"
MinFrameworkVersion="131072"
/>
<AssemblyReference
RelativePath="System.XML.dll"
AssemblyName="System.Xml, Version=2.0.0.0, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL"
MinFrameworkVersion="131072"
/>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\common.cpp"
>
</File>
<File
RelativePath=".\ProjectName.cpp"
>
</File>
<File
RelativePath=".\ProjectName.def"
>
</File>
<File
RelativePath=".\MessageCracker.cpp"
>
</File>
<File
RelativePath=".\PlaceTradeManager.cpp"
>
</File>
<File
RelativePath=".\RequestsManager.cpp"
>
</File>
<File
RelativePath=".\Stdafx.cpp"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="1"
/>
</FileConfiguration>
</File>
<File
RelativePath=".\TCPClient.cpp"
>
</File>
<Filter
Name="config"
>
<File
RelativePath=".\config\Configuration.cpp"
>
</File>
<File
RelativePath=".\config\stringfile.cpp"
>
</File>
</Filter>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\common.h"
>
</File>
<File
RelativePath=".\ProjectName.h"
>
</File>
<File
RelativePath=".\MessageCracker.h"
>
</File>
<File
RelativePath=".\Messages.h"
>
</File>
<File
RelativePath=".\Include1.h"
>
</File>
<File
RelativePath=".\Include2.h"
>
</File>
<File
RelativePath=".\resource.h"
>
</File>
<File
RelativePath=".\Stdafx.h"
>
</File>
<File
RelativePath=".\Sync.h"
>
</File>
<File
RelativePath=".\TCPClient.h"
>
</File>
<Filter
Name="config"
>
<File
RelativePath=".\config\Configuration.h"
>
</File>
<File
RelativePath=".\config\stringfile.h"
>
</File>
</Filter>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
<File
RelativePath=".\app.ico"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

最佳答案

尝试将 __declspec 放在 _CRTIMP2_PURE 之前而不是之后。这就是the documentation for __declspec(noreturn)

关于c++ STL __declspec(noreturn) 无效编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7221592/

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