gpt4 book ai didi

c++ - 包含 时 xutility 出错

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:28:25 25 4
gpt4 key购买 nike

得到了一个非常简单的C++ VC9工程,它由一个头文件和一个源文件组成,

#ifndef t_h
#define t_h
#include <string>
std::string foo();
#endif // t_h

#include "t.h"
std::string foo(){return "foo";};

这个项目的构建日志是

1>t.cpp
1>C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\xutility(945) : error C2766: explicit specialization; 'std::iterator_traits<size_t>' has already been defined
1> C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\xutility(877) : see previous definition of 'iterator_traits<unsigned __int64>'
1>C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\xutility(1472) : error C2766: explicit specialization; 'std::_Ptr_cat_helper<size_t*,size_t*>' has already been defined
1> C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\xutility(1384) : see previous definition of '_Ptr_cat_helper<unsigned __int64 *,unsigned __int64 *>'
1>C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\xutility(1478) : error C2766: explicit specialization; 'std::_Ptr_cat_helper<const size_t*,size_t*>' has already been defined
1> C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\include\xutility(1390) : see previous definition of '_Ptr_cat_helper<unsigned __int64 const *,unsigned __int64 *>'

编辑*在我得到的 xutility 文件中,这些错误在 #ifdef _LONGLONG block 中;不知道在哪里定义了 _LONGLONG*

在 32 平台上构建是可以的。有谁知道如何解决这些错误?谢谢。

项目文件,以防万一有人查看它:

<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="test"
ProjectGUID="{E9D20D01-C8A4-4477-BD8A-61BB92D3AB77}"
RootNamespace="test"
Keyword="ManagedCProj"
TargetFrameworkVersion="196613"
>
<Platforms>
<Platform
Name="Win32"
/>
<Platform
Name="x64"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="2"
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;_CRT_SECURE_NO_WARNINGS"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
StructMemberAlignment="0"
ObjectFile="$(IntDir)\"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
OutputFile="..\..\..\lib\test_x32_mtd.lib"
AdditionalLibraryDirectories=""
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug|x64"
OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="2"
ManagedExtensions="0"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=".\.."
PreprocessorDefinitions="WIN64;_DEBUG"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
StructMemberAlignment="0"
ObjectFile="$(IntDir)\"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
OutputFile="..\..\..\lib\test_x64_mtd.lib"
AdditionalLibraryDirectories=""
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="2"
ManagedExtensions="0"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=".\.."
PreprocessorDefinitions="WIN32;NDEBUG;_CRT_SECURE_NO_WARNINGS"
BasicRuntimeChecks="0"
RuntimeLibrary="2"
StructMemberAlignment="0"
ObjectFile="$(IntDir)\"
WarningLevel="3"
DebugInformationFormat="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
OutputFile="..\..\..\lib\test_x32_mt.lib"
AdditionalLibraryDirectories=""
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|x64"
OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="4"
CharacterSet="2"
ManagedExtensions="0"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
AdditionalIncludeDirectories=".\.."
PreprocessorDefinitions="WIN64;NDEBUG"
BasicRuntimeChecks="0"
RuntimeLibrary="2"
StructMemberAlignment="0"
ObjectFile="$(IntDir)\"
WarningLevel="3"
DebugInformationFormat="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLibrarianTool"
OutputFile="..\..\..\lib\test_x64_mt.lib"
AdditionalLibraryDirectories=""
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath=".\t.cpp"
>
</File>
<File
RelativePath=".\t.h"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

最佳答案

您将 LONGLONG 从 __int64 变形为 size_t。很不健康。

检查 vc/include 目录中文件的日期戳,确保它们仍然是原始文件,没有被失控的 Edit+Replace 意外编辑。

关于c++ - 包含 <string> 时 xutility 出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15640860/

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