Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Cross platform - PC & Mac
Qt 6.12 LTS is out! See what's new in the release blog

Cross platform - PC & Mac

Scheduled Pinned Locked Moved General and Desktop
7 Posts 3 Posters 3.7k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SysTech
    wrote on last edited by
    #1

    Hi All,

    I've been working on a Qt based program that will be solely for PC and have been using the MSVC2013 compiler.

    I recently got a job to do a database tool that must run both on PC and Mac. Of course Qt is the first place I thought to go because I love it. However it is not as simple as it seems I think:

    As a test I made a very simple widgets program on PC. It compiles using 32bit MSVC just fine. No warnings, no errors and it displays a nice little window.

    I then simply moved this code over to the mac. Opened Qt there (same version 5.5). Loaded the project and configured for clang64. However attempting to build generates a TON of warnings and actually some errors in some utility files I have.

    I get a fair number of:

    unknown warning group '-Winconsistent-missing-override', ignored [-Wunknown-pragmas]

    Some of the errors puzzle me a bit. I have:

    QString name = "tmrStartTimer";
    QString args = "tmrStartTimer(args)";
    

    Then I issue:

    Trace( QString( "%1(%2)" ) .arg(name).arg(args) );
    

    Trace is a function I have that writes both to qDebug and an application log file. The trace line in this code gives error:

    non-const lvalue rference to type 'QString' cannot bind to a temporary of type 'QString'

    I generally understand this message and I can fix it by changing the code to actually have a defined variable.

    But... I wonder why this is a problem? I do realize compilers differ but this seems like a pain.

    So how do you guys handle this kind of stuff cross platform? Do you ended up with a lot of #ifdefs based on platform or do you try to code to the LCD?

    A little guidance would be appreciated.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      The ton's of warning has been fixed for 5.5.1 so you shouldn't need to worry about it. How is Trace implemented ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      S 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        The ton's of warning has been fixed for 5.5.1 so you shouldn't need to worry about it. How is Trace implemented ?

        S Offline
        S Offline
        SysTech
        wrote on last edited by
        #3

        @SGaist said:

        Hi,

        The ton's of warning has been fixed for 5.5.1 so you shouldn't need to worry about it. How is Trace implemented ?

         void Trace( QString &str );
        

        The MSVC2013 compiler thinks this is ok. Clang64 doesn't like it. It wants me to basically do:

        QString str = QString( "%1(%2)" ).arg(name).arg(args);
        Trace( str );
        
        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Unless you are modifying str in Trace, you should rather use a const reference.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          S 1 Reply Last reply
          0
          • SGaistS SGaist

            Unless you are modifying str in Trace, you should rather use a const reference.

            S Offline
            S Offline
            SysTech
            wrote on last edited by
            #5

            @SGaist

            Agreed... but it doesn't fix the problem doing that. IE I still for cLang need to extract things out.

            But yes... I get lazy sometimes with the const.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              sandy.martel23
              wrote on last edited by sandy.martel23
              #6

              If you define Trace as:

              void Trace( const QString &str );

              then this will work on all compiler:

              Trace( QString( "%1(%2)" ) .arg(name).arg(args) );

              On VS2015, if I compile your code (without the const) with warnings at level 4, I get this:

              warning C4239: nonstandard extension used: 'argument': conversion from 'QString' to 'QString &'
              note: A non-const reference may only be bound to an lvalue

              Or you can disable the language extension and VS2015 will give you an error.

              So even VS knows it's wrong. For cross-platform, you better stick to standard C++ and avoid platform specific extensions.

              S 1 Reply Last reply
              0
              • S sandy.martel23

                If you define Trace as:

                void Trace( const QString &str );

                then this will work on all compiler:

                Trace( QString( "%1(%2)" ) .arg(name).arg(args) );

                On VS2015, if I compile your code (without the const) with warnings at level 4, I get this:

                warning C4239: nonstandard extension used: 'argument': conversion from 'QString' to 'QString &'
                note: A non-const reference may only be bound to an lvalue

                Or you can disable the language extension and VS2015 will give you an error.

                So even VS knows it's wrong. For cross-platform, you better stick to standard C++ and avoid platform specific extensions.

                S Offline
                S Offline
                SysTech
                wrote on last edited by
                #7

                @sandy.martel23

                Interesting... I'll have to check my warning levels on MSVC...

                I agree that my code is lacking. IE the const should be there and I am relying upon some automatic conversion. I get this and I will work to correct it.

                I will also try and see if my cLang64 likes Trace( const String &str ). I think I tried that and it still bailed but I could be wrong.

                Thanks for al the help guys!

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt
                • Unsolved