Windows Visual Studio to Linux g++
Hi,
I'm trying to switch my project from Windows Visual Studio to Linux using QtCreator.
I have a class that have this method:
Code:
virtual bool foo(class1*,int,int,QString&,QString&,class2* = NULL);
I used to use:
This is not a problem using Visual Studio, but g++ tells me that there is "no matching function for call to ..."
Thanks,
Re: Windows Visual Studio to Linux g++
try to replace the QString() parameters with actual QString instances ?
Re: Windows Visual Studio to Linux g++
Hi,
Code:
objPointer->foo(class1Pointer,0,0,qString,qString);
This code compiles without errors.
I think that I'll have to change a lot of code.
The problem is that I use to use Visual Studio on Windows because 3rd libs used are not compatible with GNU compiler on Windows, but are compatile with GNU compiler on Linux.
Maybe a list of good thinks to take account that differ from this two compilers would be great.
Thanks,
Re: Windows Visual Studio to Linux g++
Quote:
Originally Posted by
^NyAw^
Hi,
I'm trying to switch my project from Windows Visual Studio to Linux using QtCreator.
I have a class that have this method:
Code:
virtual bool foo(class1*,int,int,QString&,QString&,class2* = NULL);
I used to use:
This is not a problem using Visual Studio, but g++ tells me that there is "no matching function for call to ..."
Thanks,
I doesnt make much sense to be passing in temporaries to non-const reference parameter. That's bad of MS if compiler doesnt at least give a warning.
Comeau gives error...
http://www.comeaucomputing.com/tryitout/
So in conclusion, it may mean you should review your method because it may be that you have a design problem. Ie maybe that method tries to do too many things - as suggested by the number of arguments.
Re: Windows Visual Studio to Linux g++
g++ gives a different and more instructive warning and error when foo is not a member:
Code:
g++ -c -pipe -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I. -I. -o main.o main.cpp
main.cpp: In function ‘int main(int, char**)’:
main.
cpp:20:46: error
: invalid initialization of non
-const reference of type ‘QString
&’ from an rvalue of type ‘
QString’
main.cpp:8:6: error: in passing argument 4 of ‘bool foo(class1*, int, int, QString&, QString&, class2*)’
make: *** [main.o] Error 1
I believe the Microsoft compiler will issue an error with Disable Language Extensions turned on, and a warning at /W4. Apparently a lot of existing code uses non-const references to rvalues so changing the default behaviour would break things. Presumably the rvalue is being used when you (occasionally) don't care about the value that the function would return in the referenced parameter.
Re: Windows Visual Studio to Linux g++
Quote:
Originally Posted by
ChrisW67
Presumably the rvalue is being used when you (occasionally) don't care about the value that the function would return in the referenced parameter.
Of course then you should pass null pointers or have an overload without those parameters.