I am porting some code from Windows to Linux. I am starting to see a lot of problems relating to g++ not allowing returned objects to be passed as references. For example:
Code:
//functions
string alterString( string & inputString );
void doSomethingWithAlteredString(string & inputString);
//implementation
doSomethingWithAlteredString(alterString(aString));
With the above, doSomethingWithAlteredString will not work. g++ apparently will not accept the return of a function as a reference to an object, and complains that I am passing a string to function that takes a string&. Microsoft's compiler accepts this.
Is there any way to deal with this without making code changes wherever this occurs? Maybe a g++ compiler flag?
I know I could store the output of alterString in a variable, but this would require changes to a lot of code, and I don't see how I could do it in a function definition with default values.