使用VS 2005构建遗留代码时出错

时间:2010-08-26 07:38:57

标签: c++ visual-c++

尝试在VS2005中构建遗留代码并在VC头文件中获取错误。

d:\Compilers\Microsoft Visual Studio 8\VC\include\xutility(2096) : error C2065: '_Sb' : undeclared identifier
    d:\Compilers\Microsoft Visual Studio 8\VC\include\xutility(2176) : see reference to class template instantiation 'std::istreambuf_iterator<_Elem,_Traits>' being compiled
d:\Compilers\Microsoft Visual Studio 8\VC\include\xutility(2096) : error C3861: '_Strbuf': identifier not found
d:\Compilers\Microsoft Visual Studio 8\VC\include\xutility(2096) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
d:\Compilers\Microsoft Visual Studio 8\VC\include\xutility(2096) : error C2061: syntax error : identifier '_Sb'
d:\Compilers\Microsoft Visual Studio 8\VC\include\xutility(2097) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
d:\Compilers\Microsoft Visual Studio 8\VC\include\xutility(2098) : error C2143: syntax error : missing ';' before '{'
d:\Compilers\Microsoft Visual Studio 8\VC\include\xutility(2098) : error C2334: unexpected token(s) preceding '{'; skipping apparent function body
d:\Compilers\Microsoft Visual Studio 8\VC\include\xutility(2176) : fatal error C1075: end of file found before the left brace '{' at 'd:\Compilers\Microsoft Visual Studio 8\VC\include\xutility(15)' was matched

我发现遗留代码使用了一个向量,如果我注释掉那些变量,那么代码编译时没有任何错误。 即使我只是包含矢量标题而没有定义任何变量,我也会收到这些错误。

项目中的所有文件都是cpp文件。

我是否需要添加一些预处理程序指令或编译器设置才能使其正常工作?

2 个答案:

答案 0 :(得分:0)

您可能需要删除一些冲突的预定义宏。前导下划线后跟大写字母,如_Sb中保留用于实现。如果您将其定义为其他内容,则会出现此类错误。错误也可能是因为您已定义_Strbuf ot _Got

答案 1 :(得分:0)

您可能会发现在其中一个文件上运行预处理阶段可能会显示是否有任何扩展的宏与vector_Strbuf冲突。请参阅我的帖子,了解如何执行此操作:

Compiling a project (VS 2008) with the /p argument (preprocess to a file) doesn't compile