Code::Blocks Forums
User forums => Help => Topic started by: killerbot on November 15, 2005, 09:47:42 pm
-
Anyone aware of the following problem with the gnu compiler (or just the mingw port) ??
The following simple code does not compile :
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
vector<int> coll;
coll.push_back(10);
coll.push_back(20);
coll.push_back(30);
copy(coll.begin(), coll.end(), ostream_iterator<int>(cout, "\n"));
return 0;
} // end of main
I get :
main.cpp: In function `int main()':
main.cpp:13: error: `ostream_iterator' undeclared (first use this function)
main.cpp:13: error: (Each undeclared identifier is reported only once for each function it appears in.)
main.cpp:13: error: expected primary-expression before "int"
Process terminated with status 1 (0 minutes, 0 seconds)
3 errors, 0 warnings
I does build with M$ VC 2005, and according tothe book The C++ Standard Library (Josuttis), page 107, this is correct code.
IS there some part not supported by either :
- GNU C++ compiler
- MingW port
kind regards,
Lieven
-
also with Digital Mars I get the error :
dmc.exe -mn -c -I"C:\dm\stlport\stlport" -I"C:\dm\include" -o.Marsobjs\main.o main.cpp
copy(coll.begin(), coll.end(), ostream_iterator<int>(cout, "\n"));
^
main.cpp(13) : Error: undefined identifier 'ostream_iterator'
C:\dm\stlport\stlport\stl/_algobase.h(139) : Error: pointer required before '->', '->*' or after '*'
Had: int
return 0;
^
main.cpp(14) : Error: ';' expected following declaration of struct member
--- errorlevel 1
Process terminated with status 1 (0 minutes, 3 seconds)
3 errors, 0 warnings
-
Add #include <iterator> and it 'll work ;)
-
Yiannis, you're the greatest.
Thanks,
Lieven.