String problem when compiling with gcc3.0.2 in an Alpha with Tru64
Fri Jan 24 12:47:00 GMT 2003
a question like this was asked million times here..
1.use <iostream> instead of iostream.h
2.type 'using namespace std;' somewhere in your code..
From: email@example.com [mailto:firstname.lastname@example.org]On Behalf Of Jorge Andreu García
Sent: Friday, January 24, 2003 1:45 PM
Subject: String problem when compiling with gcc3.0.2 in an Alpha with Tru64
Trying to compile a short "Hello World!" program I have had several problems with strings. Here is the source code:
int main ()
cout << "Hola!" << endl;
pepe = "Hola con string";
cout << pepe << endl;
Easy, isn't it? Yhis is what gcc tells me:
bash-2.02$ g++302 hello.cpp -o hello.exe
hello.cpp: In function `int main()':
hello.cpp:8: `string' undeclared (first use this function)
hello.cpp:8: (Each undeclared identifier is reported only once for each
function it appears in.)
hello.cpp:8: parse error before `;' token
hello.cpp:9: `pepe' undeclared (first use this function)
Can somebody help me? I have tried including "bits/stringfwd.h" (where I have found a typedef defining string) but still have the same problem. Somewhere in this mailing list I have read about putting std::string and it seems to work, but the problem is I have to migrate a lot of source files from Linux(Mandrake) where previous program works to Tru64 machine and there are lots of string defined and change all is goiung to be a lot of work, so I hope another way to do this can be possible.
Thnaks in advance:
More information about the Gcc-help