I don't care about all the new Managed C++, CLR stuff, etc ... not just yet. Right now, just want to compile the most basic, could't -be-simpler C++ program that most C++ compilers could already handle 10 or 15 years ago. And surprisingly, VC++ 2005 EE fails to do that. Or if it can, the Microsoft VC team certainly do not make it easy. I love to be told that I'm wrong or missing something really stupid. That way, I am embarrased for 10 minutes but can still go on. The alternative is I'm right but get stuck for who-knows-how-long until the next fix, if any. I choose the former.
I tried Alt+F7 (configure project properties) and tried many different compiling options, but still, if I include <string>, then the compile fails. For now I give up and would like to ask everyone else. Why does MS have to ake it so hard
Here's the sample:
TestSTL.h
#ifndef __TEST_STL__
#define __TEST_STL__
class TestSTL
{
public:
TestSTL();
virtual ~TestSTL();
};
#endif
TestSTL.cpp
#include <string> //This is the killer
#include "TestSTL.h"
TestSTL::TestSTL()
{
//Do nothing
}
TestSTL::~TestSTL()
{
//Do nothing
}
int main(int argc, char **argv) {
//Do nothing
return 0;
}

VC++ Exp Edition 2005 fails to compile with STL string
luigi_loaec
One way to reproduce this is fire up VC2005 EE, select New and use the "Empty Project" wizard and start adding or writing your own simple program with #include <string> in it. Make it even easier for yourself. Add one single cpp file called main.cpp as follow:
main.cpp
#include <string>
#include <iostream>
int main()
{
std::string hello("Hello world");
std::cout << hello << std::endl;
return 0;
}
As you can see, absolutely there's no VC6 involved in those steps. You will see the compilation fails. So why is it
Gossimmer
dmssjt
Ken Elmy
What error is there
I had VC Exp Edition 2005 installed, but did not use it, instead, I used my VC6.0 in the same machine to compile, and here it goes:
Q:\peter\STL>cl testSTL.cpp
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for 80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.
testSTL.cpp
H:\Program Files\Microsoft Visual Studio\VC98\include\istream(547) : warning C45
30: C++ exception handler used, but unwind semantics are not enabled. Specify -G
X
H:\Program Files\Microsoft Visual Studio\VC98\include\ostream(234) : warning C45
30: C++ exception handler used, but unwind semantics are not enabled. Specify -G
X
H:\Program Files\Microsoft Visual Studio\VC98\include\ostream(229) : whi
le compiling class-template member function 'class std::basic_ostream<char,struc
t std::char_traits<char> > &__thiscall std::basic_ostream<char,struct std::char_
traits<char> >::put(char)'
H:\Program Files\Microsoft Visual Studio\VC98\include\ostream(234) : warning C45
30: C++ exception handler used, but unwind semantics are not enabled. Specify -G
X
H:\Program Files\Microsoft Visual Studio\VC98\include\ostream(229) : whi
le compiling class-template member function 'class std::basic_ostream<unsigned s
hort,struct std::char_traits<unsigned short> > &__thiscall std::basic_ostream<un
signed short,struct std::char_traits<unsigned short> >::put(unsigned short)'
H:\Program Files\Microsoft Visual Studio\VC98\include\istream(46) : warning C453
0: C++ exception handler used, but unwind semantics are not enabled. Specify -GX
H:\Program Files\Microsoft Visual Studio\VC98\include\istream(41) : whil
e compiling class-template member function 'bool __thiscall std::basic_istream<c
har,struct std::char_traits<char> >::ipfx(bool)'
H:\Program Files\Microsoft Visual Studio\VC98\include\istream(46) : warning C453
0: C++ exception handler used, but unwind semantics are not enabled. Specify -GX
H:\Program Files\Microsoft Visual Studio\VC98\include\istream(41) : whil
e compiling class-template member function 'bool __thiscall std::basic_istream<u
nsigned short,struct std::char_traits<unsigned short> >::ipfx(bool)'
H:\Program Files\Microsoft Visual Studio\VC98\include\xstring(525) : warning C45
30: C++ exception handler used, but unwind semantics are not enabled. Specify -G
X
H:\Program Files\Microsoft Visual Studio\VC98\include\xstring(521) : whi
le compiling class-template member function 'void __thiscall std::basic_string<c
har,struct std::char_traits<char>,class std::allocator<char> >::_Copy(unsigned i
nt)'
Microsoft (R) Incremental Linker Version 6.00.8447
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
/out:testSTL.exe
testSTL.obj
Q:\peter\STL>cl testSTL.cpp -GX
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for 80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.
testSTL.cpp
Microsoft (R) Incremental Linker Version 6.00.8447
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
/out:testSTL.exe
testSTL.obj
As you can see, there are no errors. I am quite disappointed with the level of support provided by Jonathan Caves....
roughfalls
SO... what/where is the failure !!!
Stanley Daniel
Will MC
1>------ Build started: Project: TestSTL, Configuration: Debug Win32 ------
1>Compiling...
1>TestSTL.cpp
1>C:\Program Files\Microsoft Visual Studio\VC98\Include\utility(81) : warning C4346: '_It::iterator_category' : dependent name is not a type
1> prefix with 'typename' to indicate a type
1> C:\Program Files\Microsoft Visual Studio\VC98\Include\utility(84) : see reference to class template instantiation 'std::iterator_traits<_It>' being compiled
1>C:\Program Files\Microsoft Visual Studio\VC98\Include\utility(81) : error C2146: syntax error : missing ';' before identifier 'iterator_category'
1>C:\Program Files\Microsoft Visual Studio\VC98\Include\utility(81) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files\Microsoft Visual Studio\VC98\Include\utility(82) : warning C4346: '_It::value_type' : dependent name is not a type
1> prefix with 'typename' to indicate a type
1>C:\Program Files\Microsoft Visual Studio\VC98\Include\utility(82) : error C2146: syntax error : missing ';' before identifier 'value_type'
1>C:\Program Files\Microsoft Visual Studio\VC98\Include\utility(82) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files\Microsoft Visual Studio\VC98\Include\utility(83) : warning C4346: '_It::distance_type' : dependent name is not a type
1> prefix with 'typename' to indicate a type
1>C:\Program Files\Microsoft Visual Studio\VC98\Include\utility(83) : error C2146: syntax error : missing ';' before identifier 'distance_type'
1>C:\Program Files\Microsoft Visual Studio\VC98\Include\utility(83) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files\Microsoft Visual Studio\VC98\Include\utility(224) : warning C4348: 'std::istreambuf_iterator' : redefinition of default parameter : parameter 2
1> C:\Program Files\Microsoft Visual Studio\VC98\Include\utility(279) : see declaration of 'std::istreambuf_iterator'
1>C:\Program Files\Microsoft Visual Studio\VC98\Include\utility(226) : warning C4346: '_Tr::off_type' : dependent name is not a type
1> prefix with 'typename' to indicate a type
1> C:\Program Files\Microsoft Visual Studio\VC98\Include\utility(279) : see reference to class template instantiation 'std::istreambuf_iterator<_E,_Tr>' being compiled
1>C:\Program Files\Microsoft Visual Studio\VC98\Include\utility(226) : error C2923: 'std::iterator' : '_Tr::off_type' is not a valid template type argument for parameter '_D'
1>C:\Program Files\Microsoft Visual Studio\VC98\Include\utility(226) : error C2955: 'std::iterator' : use of class template requires template argument list
1> C:\Program Files\Microsoft Visual Studio\VC98\Include\utility(71) : see declaration of 'std::iterator'
1>C:\Program Files\Microsoft Visual Studio\VC98\Include\utility(231) : warning C4346: '_Tr::int_type' : dependent name is not a type
1> prefix with 'typename' to indicate a type
1>C:\Program Files\Microsoft Visual Studio\VC98\Include\utility(231) : error C2146: syntax error : missing ';' before identifier 'int_type'
1>C:\Program Files\Microsoft Visual Studio\VC98\Include\utility(231) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files\Microsoft Visual Studio\VC98\Include\utility(289) : warning C4348: 'std::ostreambuf_iterator' : redefinition of default parameter : parameter 2
1> C:\Program Files\Microsoft Visual Studio\VC98\Include\utility(318) : see declaration of 'std::ostreambuf_iterator'
1>C:\Program Files\Microsoft Visual Studio\VC98\Include\xstring(25) : warning C4346: '_A::size_type' : dependent name is not a type
1> prefix with 'typename' to indicate a type
1> C:\Program Files\Microsoft Visual Studio\VC98\Include\xstring(597) : see reference to class template instantiation 'std::basic_string<_E,_Tr,_A>' being compiled
1>C:\Program Files\Microsoft Visual Studio\VC98\Include\xstring(25) : error C2146: syntax error : missing ';' before identifier 'size_type'
1>C:\Program Files\Microsoft Visual Studio\VC98\Include\xstring(25) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files\Microsoft Visual Studio\VC98\Include\xstring(26) : warning C4346: '_A::difference_type' : dependent name is not a type
1> prefix with 'typename' to indicate a type
1>C:\Program Files\Microsoft Visual Studio\VC98\Include\xstring(26) : error C2146: syntax error : missing ';' before identifier 'difference_type'
1>C:\Program Files\Microsoft Visual Studio\VC98\Include\xstring(26) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files\Microsoft Visual Studio\VC98\Include\xstring(27) : warning C4346: '_A::pointer' : dependent name is not a type
1> prefix with 'typename' to indicate a type
1>C:\Program Files\Microsoft Visual Studio\VC98\Include\xstring(27) : error C2146: syntax error : missing ';' before identifier 'pointer'
1>C:\Program Files\Microsoft Visual Studio\VC98\Include\xstring(27) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files\Microsoft Visual Studio\VC98\Include\xstring(28) : warning C4346: '_A::const_pointer' : dependent name is not a type
1> prefix with 'typename' to indicate a type
1>C:\Program Files\Microsoft Visual Studio\VC98\Include\xstring(28) : error C2146: syntax error : missing ';' before identifier 'const_pointer'
1>C:\Program Files\Microsoft Visual Studio\VC98\Include\xstring(28) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files\Microsoft Visual Studio\VC98\Include\xstring(29) : warning C4346: '_A::reference' : dependent name is not a type
1> prefix with 'typename' to indicate a type
1>C:\Program Files\Microsoft Visual Studio\VC98\Include\xstring(29) : error C2146: syntax error : missing ';' before identifier 'reference'
1>C:\Program Files\Microsoft Visual Studio\VC98\Include\xstring(29) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files\Microsoft Visual Studio\VC98\Include\xstring(30) : warning C4346: '_A::const_reference' : dependent name is not a type
1> prefix with 'typename' to indicate a type
1>C:\Program Files\Microsoft Visual Studio\VC98\Include\xstring(30) : error C2146: syntax error : missing ';' before identifier 'const_reference'
1>C:\Program Files\Microsoft Visual Studio\VC98\Include\xstring(30) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files\Microsoft Visual Studio\VC98\Include\xstring(31) : warning C4346: '_A::value_type' : dependent name is not a type
1> prefix with 'typename' to indicate a type
1>C:\Program Files\Microsoft Visual Studio\VC98\Include\xstring(31) : error C2146: syntax error : missing ';' before identifier 'value_type'
1>C:\Program Files\Microsoft Visual Studio\VC98\Include\xstring(31) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>C:\Program Files\Microsoft Visual Studio\VC98\Include\xstring(32) : warning C4346: '_A::pointer' : dependent name is not a type
1> prefix with 'typename' to indicate a type
1>C:\Program Files\Microsoft Visual Studio\VC98\Include\xstring(32) : error C2144: syntax error : 'std::iterator' should be preceded by ';'
1>C:\Program Files\Microsoft Visual Studio\VC98\Include\xstring(32) : error C2208: 'std::iterator' : no members defined using this type
1>C:\Program Files\Microsoft Visual Studio\VC98\Include\xstring(32) : fatal error C1903: unable to recover from previous error(s); stopping compilation
1>Build log was saved at "file://c:\VcExpressWorkSpace\TestSTL\TestSTL\Debug\BuildLog.htm"
1>TestSTL - 27 error(s), 15 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========