String problem when compiling with gcc3.0.2 in an Alpha with Tru64
Jorge Andreu García
jandreu@gmv.es
Fri Jan 24 12:45:00 GMT 2003
Hello.
Trying to compile a short "Hello World!" program I have had several problems with strings. Here is the source code:
#include <iostream.h>
#include <string>
//#include <bits/stringfwd.h>
int main ()
{
cout << "Hola!" << endl;
string pepe;
pepe = "Hola con string";
cout << pepe << endl;
return 0;
}
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:
Jorge Andreu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://gcc.gnu.org/pipermail/gcc-help/attachments/20030124/f1980349/attachment.htm>
More information about the Gcc-help
mailing list