有一个非常简单的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
块中;不知道在哪里定义了_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>
答案 0 :(得分:1)
你让LONGLONG从__int64变形为size_t。非常不健康。
检查vc / include目录中文件的日期戳,确保它们仍然是原始文件,并且不会被失控的Edit + Replace意外编辑。