M
Micha
Hi,
i am trying to get to run this piece of code.
#include <qstring.h>
//:1
#include <list>
//:2
#include <algorithm>
//:3
#include <iostream> //:4
//:5
void myTestF(const std::string& str)
{ //:6
//:7
std::string val1( std::string(str) ); //:8
std::string val2( std::string("123") ); //:9
//:10
char * testChar = NULL; //:11
std::string val3( testChar ); //:12
//:13
QString qStr(str); //:14
//:15
std::string val4( qStr.ascii() ); //:16
//:17
std::string val5( std::string( QString(str).ascii() ) ); //:18
//:19
} //:20
//:21
int main() { //:22
std::cout << "hello World!\n"; //:23
return 0; //:24
} //:25
G++ 3.3.2 won't accept line #18, commenting out this line makes the
whole
program compilable. Starting from line #18 i tried to decompose this
line into
it's statements in order to encircle the issue - which you can see in
the lines 8-16.
Lines 8-16 are accepted, line 18 is rejected. Why? ;-)
thanks, Micha
PS : this piece of code will be accepted by aCC (hp-compiler),
currently i am porting
a program from aCC to gcc - this is how I got stuck on this. On some
web-page i read,
that aCC is kept anso-compatible. Mhh i ran my gcc with the -ansi flag
- it didn't help.
Will the current gcc compile the program? (can't install one myself
here)
i am trying to get to run this piece of code.
#include <qstring.h>
//:1
#include <list>
//:2
#include <algorithm>
//:3
#include <iostream> //:4
//:5
void myTestF(const std::string& str)
{ //:6
//:7
std::string val1( std::string(str) ); //:8
std::string val2( std::string("123") ); //:9
//:10
char * testChar = NULL; //:11
std::string val3( testChar ); //:12
//:13
QString qStr(str); //:14
//:15
std::string val4( qStr.ascii() ); //:16
//:17
std::string val5( std::string( QString(str).ascii() ) ); //:18
//:19
} //:20
//:21
int main() { //:22
std::cout << "hello World!\n"; //:23
return 0; //:24
} //:25
G++ 3.3.2 won't accept line #18, commenting out this line makes the
whole
program compilable. Starting from line #18 i tried to decompose this
line into
it's statements in order to encircle the issue - which you can see in
the lines 8-16.
Lines 8-16 are accepted, line 18 is rejected. Why? ;-)
thanks, Micha
PS : this piece of code will be accepted by aCC (hp-compiler),
currently i am porting
a program from aCC to gcc - this is how I got stuck on this. On some
web-page i read,
that aCC is kept anso-compatible. Mhh i ran my gcc with the -ansi flag
- it didn't help.
Will the current gcc compile the program? (can't install one myself
here)