tags:

views:

25

answers:

2

Trying to build a legacy code in VS2005 and get errors in VC header files.

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

I find the legacy code uses a vector and if I comment out those variables then the code compiles without any errors. I get these errors even if I just include vector header without defining any variable.

All the files in the project are cpp files.

Do I need to add some preprocessor directives or compiler settings to get this working?

A: 

You probably need to remove some conflicting predefined macros. Leading underscores followed by uppercase letters, as in _Sb are reserved for the implementation. If you have that defined as something else, you'll get such errors. It's also possible the errors are because you've defined _Strbuf ot _Got.

MSalters
A: 

You may find that running the pre-process phase on one of the files might show if any macros are being expanded that conflict with vector or _Strbuf. See my post on how to do this:

http://stackoverflow.com/questions/3570024/compiling-a-project-vs-2008-with-the-p-argument-preprocess-to-a-file-doesnt/3570083#3570083

the_mandrill
Thanks. I preprocessed the file that fails to compile, but don't see any conflicting definition for `vector` or `_Strbuf` in .i file
vinaym
Now that you have the .i file, try commenting out regions of it to isolate the code it's complaining about (ie do a binary search).
the_mandrill