1

我正在使用 Visual Studio 2010 并尝试

#include <string>

在 C++ 配置的项目中。但是,当我尝试这样做时,我得到了 100 多个错误,如本文底部所示。我还尝试了包含算法、iostream 和 map 以查看是否得到相同的结果(我确实做到了),这让我相信它可能与 STL 或包含 .h 文件以外的任何内容有关。我注意到里面已经有 STL 文件了

C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\

目录。通过尝试使用字符串,我是否以某种方式干扰了某种预设的 VS STL?还是这是其他问题?

我还尝试获取 STL 的源代码并将其放在与我的 .cpp 文件相同的目录中的文件夹中以在那里引用它,但随后我遇到了 STL 文件中包含的一系列问题。有任何想法吗?

1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\crtdefs.h(436): error C2371: 'ptrdiff_t' : redefinition; 不同的基本类型 1>
c:\cats\executive\common_include\stddef.h(26) :参见“ptrdiff_t”声明 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cstdlib(32 ):错误 C2039:“lldiv_t”:不是“global namespace'' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cstdlib(32): error C2873: 'lldiv_t' : symbol cannot be used in a using-declaration 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cstdlib(34): error C2039: 'llabs' : is not a member of '全局命名空间”的成员 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cstdlib(34):错误 C2873:“llabs” : 符号不能用于 using-declaration 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cstdlib(34): error C2039: 'lldiv' : is not a member of 'global namespace'' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cstdlib(34): error C2873: 'lldiv' : symbol cannot be used in a using-declaration 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\malloc.h(104): error C2375: 'calloc' : redefinition; different linkage 1>
c:\cats\executive\common_include\stdlib.h(89) : see declaration of 'calloc' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\malloc.h(105): error C2375: 'free' : redefinition; different linkage 1>
c:\cats\executive\common_include\stdlib.h(90) : see declaration of 'free' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\malloc.h(106): error C2375: 'malloc' : redefinition; different linkage 1>
c:\cats\executive\common_include\stdlib.h(91) : see declaration of 'malloc' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\malloc.h(108): error C2375: 'realloc' : redefinition; different linkage 1>
c:\cats\executive\common_include\stdlib.h(92) : see declaration of 'realloc' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\malloc.h(236): error C3861: 'free': identifier not found 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\wchar.h(55): error C2371: '_iobuf' : redefinition; different basic types 1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\cstdio(34) : see declaration of '_iobuf' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\wchar.h(65): error C2371: 'FILE' : redefinition; different basic types 1>
c:\cats\executive\common_include\stdio.h(133) : see declaration of 'FILE' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\wchar.h(76): warning C4005: 'stdin' : macro redefinition 1> c:\cats\executive\common_include\stdio.h(146) : see previous definition of 'stdin' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\wchar.h(77): warning C4005: 'stdout' : macro redefinition 1>
c:\cats\executive\common_include\stdio.h(147) : see previous definition of 'stdout' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\wchar.h(78): warning C4005: 'stderr' : macro redefinition 1> c:\cats\executive\common_include\stdio.h(148) : see previous definition of 'stderr' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\wchar.h(1110): error C2011: 'tm' : 'struct' type redefinition 1>
c:\cats\executive\common_include\time.h(69) : see declaration of 'tm' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\wtime.inl(48): error C2664: '_wctime64' : cannot convert parameter 1 from 'const time_t *' to 'const __time64_t *' 1>
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\wtime.inl(54): error C2664: 'errno_t _wctime64_s(wchar_t *,size_t,const __time64_t *)' : cannot convert parameter 3 from 'const time_t *' to 'const __time64_t *' 1>
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\wchar.h(1187): error C2375: 'memmove' : redefinition; different linkage 1>
c:\cats\executive\common_include\string.h(35) : see declaration of 'memmove' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\wchar.h(1223): error C3861: 'memmove': identifier not found 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(19): error C2039: 'acosf' : is not a member of '
全局命名空间'' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(19): error C2873: 'acosf' : symbol cannot be used in a using-declaration 1>c:\程序文件 (x86)\microsoft visual studio 10.0\vc\include\cmath(19): error C2039: 'asinf' : is not a member of ' global namespace'' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(19): error C2873: 'asinf' : symbol cannot be used in a using-declaration 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(20): error C2039: 'atanf' : is not a member of 'global namespace'' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(20): 错误 C2873: 'atanf': 符号不能用于 using-declaration 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath( 20): 错误 C2039: 'atan2f' : 不是'的成员global namespace'' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(20): error C2873: 'atan2f' : symbol cannot be used in a using-declaration 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(20): error C2039: 'ceilf' : is not a member of '全局命名空间'' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(20): error C2873: 'ceilf' : symbol cannot be used in a using-declaration 1>c:\程序文件 (x86)\microsoft visual studio 10.0\vc\include\cmath(21): error C2039: 'cosf' : is not a member of ' global namespace'' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(21): error C2873: 'cosf' : symbol cannot be used in a using-declaration 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(21): error C2039: 'coshf' : is not a member of 'global namespace'' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(21): 错误 C2873: 'coshf': 符号不能用于 using-declaration 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath( 21): 错误 C2039: 'expf' : 不是'的成员global namespace'' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(21): error C2873: 'expf' : symbol cannot be used in a using-declaration 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(22): error C2039: 'fabsf' : is not a member of '全局命名空间'' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(22): error C2873: 'fabsf' : symbol cannot be used in a using-declaration 1>c:\程序文件 (x86)\microsoft visual studio 10.0\vc\include\cmath(22): error C2039: 'floorf' : is not a member of ' global namespace'' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(22): error C2873: 'floorf' : symbol cannot be used in a using-declaration 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(22): error C2039: 'fmodf' : is not a member of 'global namespace'' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(22): 错误 C2873: 'fmodf': 符号不能用于 using-declaration 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath( 23): 错误 C2039: 'freexpf' : 不是'的成员global namespace'' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(23): error C2873: 'frexpf' : symbol cannot be used in a using-declaration 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(23): error C2039: 'ldexpf' : is not a member of '全局命名空间'' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(23): error C2873: 'ldexpf' : symbol cannot be used in a using-declaration 1>c:\程序文件 (x86)\microsoft visual studio 10.0\vc\include\cmath(23): error C2039: 'logf' : is not a member of ' global namespace'' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(23): error C2873: 'logf' : symbol cannot be used in a using-declaration 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(24): error C2039: 'log10f' : is not a member of 'global namespace'' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(24): 错误 C2873: 'log10f': 符号不能用于 using-declaration 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath( 24): 错误 C2039: 'modff' : 不是'的成员global namespace'' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(24): error C2873: 'modff' : symbol cannot be used in a using-declaration 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(24): error C2039: 'powf' : is not a member of '全局命名空间'' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(24): error C2873: 'powf' : symbol cannot be used in a using-declaration 1>c:\程序文件 (x86)\microsoft visual studio 10.0\vc\include\cmath(25): error C2039: 'sinf' : is not a member of ' global namespace'' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(25): error C2873: 'sinf' : symbol cannot be used in a using-declaration 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(25): error C2039: 'sinhf' : is not a member of 'global namespace'' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(25): 错误 C2873: 'sinhf': 符号不能用于 using-declaration 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath( 25): 错误 C2039: 'sqrtf' : 不是'的成员global namespace'' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(25): error C2873: 'sqrtf' : symbol cannot be used in a using-declaration 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(26): error C2039: 'tanf' : is not a member of '全局命名空间'' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(26): error C2873: 'tanf' : symbol cannot be used in a using-declaration 1>c:\程序文件 (x86)\microsoft visual studio 10.0\vc\include\cmath(26): error C2039: 'tanhf' : is not a member of ' global namespace'' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(26): error C2873: 'tanhf' : symbol cannot be used in a using-declaration 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(28): error C2039: 'acosl' : is not a member of 'global namespace'' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(28): 错误 C2873: 'acosl': 符号不能用于 using-declaration 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath( 28): 错误 C2039: 'asinl' : 不是'的成员global namespace'' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(28): error C2873: 'asinl' : symbol cannot be used in a using-declaration 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(29): error C2039: 'atanl' : is not a member of '全局命名空间'' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(29): error C2873: 'atanl' : symbol cannot be used in a using-declaration 1>c:\程序文件 (x86)\microsoft visual studio 10.0\vc\include\cmath(29): error C2039: 'atan2l' : is not a member of ' global namespace'' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(29): error C2873: 'atan2l' : symbol cannot be used in a using-declaration 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(29): error C2039: 'ceill' : is not a member of 'global namespace'' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(29): 错误 C2873: 'ceill': 符号不能用于 using-declaration 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath( 30): 错误 C2039: 'cosl' : 不是'的成员global namespace'' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(30): error C2873: 'cosl' : symbol cannot be used in a using-declaration 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(30): error C2039: 'coshl' : is not a member of '全局命名空间'' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(30): error C2873: 'coshl' : symbol cannot be used in a using-declaration 1>c:\程序文件 (x86)\microsoft visual studio 10.0\vc\include\cmath(30): error C2039: 'expl' : is not a member of ' global namespace'' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(30): error C2873: 'expl' : symbol cannot be used in a using-declaration 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(31): error C2039: 'fabsl' : is not a member of 'global namespace'' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(31): 错误 C2873: 'fabsl': 符号不能用于 using-declaration 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath( 31): 错误 C2039: 'floorl' : 不是'的成员global namespace'' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(31): error C2873: 'floorl' : symbol cannot be used in a using-declaration 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(31): error C2039: 'fmodl' : is not a member of '全局命名空间'' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(31): error C2873: 'fmodl' : symbol cannot be used in a using-declaration 1>c:\程序文件 (x86)\microsoft visual studio 10.0\vc\include\cmath(32): error C2039: 'frexpl' : is not a member of ' global namespace'' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(32): error C2873: 'frexpl' : symbol cannot be used in a using-declaration 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(32): error C2039: 'ldexpl' : is not a member of 'global namespace'' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(32): 错误 C2873: 'ldexpl': 符号不能用于 using-declaration 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath( 32): 错误 C2039: 'logl' : 不是'的成员global namespace'' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(32): error C2873: 'logl' : symbol cannot be used in a using-declaration 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(33): error C2039: 'log10l' : is not a member of '全局命名空间'' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(33): error C2873: 'log10l' : symbol cannot be used in a using-declaration 1>c:\程序文件 (x86)\microsoft visual studio 10.0\vc\include\cmath(33): error C2039: 'modfl' : is not a member of ' global namespace'' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(33): error C2873: 'modfl' : symbol cannot be used in a using-declaration 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(33): error C2039: 'powl' : is not a member of 'global namespace'' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(33): 错误 C2873: 'powl': 符号不能用于 using-declaration 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath( 34): 错误 C2039: 'sinl' : is not a member of 'global namespace'' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(34): error C2873: 'sinl' : symbol cannot be used in a using-declaration 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(34): error C2039: 'sinhl' : is not a member of '全局命名空间'' 1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\cmath(34): error C2873: 'sinhl' : symbol cannot be used in a using-declaration 1>c:\程序文件 (x86)\microsoft visual studio 10.0\vc\include\cmath(34):致命错误 C1003:错误计数超过 100;停止编译 ========== 构建:0 成功,1 失败,0 最新,0 跳过 ==========

4

1 回答 1

1

1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\crtdefs.h(436): error C2371: 'ptrdiff_t' : redefinition; 不同的基本类型

这很可能是您如何配置项目的问题。

我要检查的第一件事是确保您已在项目设置中WIN64定义(和WIN32 未定义)。

于 2013-07-26T18:14:08.933 回答