Results 1 to 6 of 6

Thread: Windows Visual Studio to Linux g++

  1. #1
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default 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:

    Qt Code:
    1. virtual bool foo(class1*,int,int,QString&,QString&,class2* = NULL);
    To copy to clipboard, switch view to plain text mode 

    I used to use:
    Qt Code:
    1. objPointer->foo(class1Pointer,0,0,QString(),QString());
    To copy to clipboard, switch view to plain text mode 

    This is not a problem using Visual Studio, but g++ tells me that there is "no matching function for call to ..."

    Thanks,
    Òscar Llarch i Galán

  2. #2
    Join Date
    Dec 2009
    Posts
    128
    Thanks
    7
    Thanked 14 Times in 14 Posts
    Platforms
    Unix/X11 Windows

    Default Re: Windows Visual Studio to Linux g++

    try to replace the QString() parameters with actual QString instances ?

  3. #3
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Windows Visual Studio to Linux g++

    Hi,
    Qt Code:
    1. QString qString;
    2. objPointer->foo(class1Pointer,0,0,qString,qString);
    To copy to clipboard, switch view to plain text mode 

    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,
    Òscar Llarch i Galán

  4. #4
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Windows Visual Studio to Linux g++

    Quote Originally Posted by ^NyAw^ View Post
    Hi,

    I'm trying to switch my project from Windows Visual Studio to Linux using QtCreator.

    I have a class that have this method:

    Qt Code:
    1. virtual bool foo(class1*,int,int,QString&,QString&,class2* = NULL);
    To copy to clipboard, switch view to plain text mode 

    I used to use:
    Qt Code:
    1. objPointer->foo(class1Pointer,0,0,QString(),QString());
    To copy to clipboard, switch view to plain text mode 

    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.
    Last edited by amleto; 6th October 2011 at 19:34.

  5. #5
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Windows Visual Studio to Linux g++

    g++ gives a different and more instructive warning and error when foo is not a member:
    Qt Code:
    1. 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
    2. main.cpp: In function ‘int main(int, char**)’:
    3. main.cpp:20:46: error: invalid initialization of non-const reference of type ‘QString&’ from an rvalue of type ‘QString’
    4. main.cpp:8:6: error: in passing argument 4 of ‘bool foo(class1*, int, int, QString&, QString&, class2*)’
    5. make: *** [main.o] Error 1
    To copy to clipboard, switch view to plain text mode 

    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.

  6. The following user says thank you to ChrisW67 for this useful post:

    ^NyAw^ (7th October 2011)

  7. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Windows Visual Studio to Linux g++

    Quote Originally Posted by ChrisW67 View Post
    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Replies: 0
    Last Post: 19th April 2011, 14:25
  2. OFF: WinGDB - Linux debugging under Visual Studio
    By WinGDB in forum General Discussion
    Replies: 1
    Last Post: 7th March 2010, 01:11
  3. Replies: 7
    Last Post: 16th November 2009, 15:40
  4. Qt 4.3.0 to 4.5.3 Windows Visual Studio
    By ^NyAw^ in forum Installation and Deployment
    Replies: 3
    Last Post: 30th October 2009, 23:08
  5. Qt 4 for Windows CE : Visual Studio 2005 integration
    By pscheven in forum Installation and Deployment
    Replies: 4
    Last Post: 20th March 2008, 08:36

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.