Tanks for the answers so far. I know, the piece of code I've posted
so far makes little sense and is not elegant or efficient at all. I
used it to encircle my problem. Which occured while porting a bigger
project from aCC,hp-ux to gcc,solaris.
My hope was that I could pass some magic switches to gcc and make it
comppile the code without manual patching - which could end up with
lots of stupid work for me.
Besides that I got interested in the problem itself.
The (shortened) original code is :
#include <qstring.h>
#include <iostream>
std::string someFunction(const std::string& str)
{
std::string val(std::string(QString(str).stripWhiteSpace().ascii()));
std::replace(val.begin(),val.end(), '/', '_');
return(val);
}
int main() {
std::cout << "hello World!\n";
return 0;
}
And the gcc's output is :
make
g++ -c -Wall -W -O2 -DQT_NO_DEBUG -DQT_SHARED -DQT_THREAD_SUPPORT -I/
home2/eng/qt/mkspecs/solaris-g++ -I. -I.. -I/home2/eng/qt/include -o
testIssue2.o testIssue2.cpp
testIssue2.cpp: In function `std::string someFunction(const
std::string&)':
testIssue2.cpp:6: error: parse error before `.' token
testIssue2.cpp:8: error: request for member `begin' in `val(...)',
which is of
non-aggregate type `std::string ()(...)'
testIssue2.cpp:8: error: request for member `end' in `val(...)', which
is of
non-aggregate type `std::string ()(...)'
testIssue2.cpp:10: error: conversion from `std::string (*)(...)' to
non-scalar
type `std::string' requested
*** Error code 1
As I understood it so far - gcc interprets
std::string
val(std::string(QString(str).stripWhiteSpace().ascii()));
as a function instead of a variable definition which was clearly ment
here - at least for the aCC ;-).
1) Any chances to make it compile with a current gcc without manual
patching?
behaviour. In Vc++2005 the following will not compile: