Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. What could cause clang to error, but gcc compiles it anyway?
Forum Updated to NodeBB v4.3 + New Features

What could cause clang to error, but gcc compiles it anyway?

Scheduled Pinned Locked Moved Solved General and Desktop
19 Posts 3 Posters 2.4k Views 3 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.
  • fcarneyF Offline
    fcarneyF Offline
    fcarney
    wrote on last edited by
    #7

    I built the same project with the desktop gcc (x86) and the errors are gone. There is something weird about the arm gcc.

    C++ is a perfectly valid school of magic.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mchinand
      wrote on last edited by
      #8

      What versions of Qt and QtCreator are you using?

      1 Reply Last reply
      0
      • fcarneyF fcarney
            QObject::connect(this, SIGNAL(doQuit()), qApp, SLOT(quit()), Qt::QueuedConnection);
        
            QObject::connect(WebSocketClient::instance(), SIGNAL(connected()),
                             this, SLOT(webSct_connected()));
            QObject::connect(WebSocketClient::instance(), SIGNAL(disconnected()),
                             this, SLOT(webSct_disconnected()));
            QObject::connect(WebSocketClient::instance(), SIGNAL(ping_status(int, int)),
                             this, SLOT(webSct_ping_status(int, int)));
        
            QObject::connect(this, &XMUI::doQuit, qApp, &QApplication::quit, Qt::QueuedConnection);
        

        The first lines have semantic errors. The last line no errors. But this does not explain why. I have other weird errors that don't affect the compile. Like telling me I don't have enough args for a function when the function has default args. I am thinking this is something to do with my arm compiler. The desktop gcc compiler isn't doing this. So I have to assume the arm compiler is configured weird. I will try to see where that takes me.

        Just to give more info. The other connects are saying that they cannot convert XMUI (QObject derived) to const QObject*. That is the "this" parameter.

        /home/fcarney/git/xmc-tools/cl-sysroot/cortexa15hf-vfp-neon-linux-gnueabi/usr/local/Qt-5.15.1/include/QtCore/qobject.h:222: candidate function not viable: no known conversion from 'XMUI *' to 'const QObject *' for 1st argument
        

        However, the last connect should be saying exactly the same thing.

        kshegunovK Offline
        kshegunovK Offline
        kshegunov
        Moderators
        wrote on last edited by kshegunov
        #9

        @fcarney said in What could cause clang to error, but gcc compiles it anyway?:

        The first lines have semantic errors. The last line no errors. But this does not explain why. I have other weird errors that don't affect the compile. Like telling me I don't have enough args for a function when the function has default args. I am thinking this is something to do with my arm compiler. The desktop gcc compiler isn't doing this. So I have to assume the arm compiler is configured weird. I will try to see where that takes me.

        This has nothing to do with the actual compiler, it's the code model that generates them (hence my original question). Personally I hate the machine telling me what kind of garbage code I write, so I use the good ol' stupid code model that doesn't generate no such diagnostics. :D

        Read and abide by the Qt Code of Conduct

        1 Reply Last reply
        1
        • M Offline
          M Offline
          mchinand
          wrote on last edited by
          #10

          Do have the Q_OBJECT macro in your XMUI header?

          fcarneyF 1 Reply Last reply
          0
          • M mchinand

            Do have the Q_OBJECT macro in your XMUI header?

            fcarneyF Offline
            fcarneyF Offline
            fcarney
            wrote on last edited by
            #11

            @mchinand It doesn't matter if I have Q_OBJECT in there (it does). Compiling with a different Kit made all the errors disappear. I have something wrong with my Kit or Arm compiler installation. The gcc kit for the OS doesn't cause this. The Arm kit does. Strangely, a guy I work with has same exact kit and doesn't see these errors when compiling to Arm.

            @kshegunov
            I will have to research what "code model" means and why it might affect the error messages. Thanks for the tip.

            C++ is a perfectly valid school of magic.

            1 Reply Last reply
            0
            • fcarneyF Offline
              fcarneyF Offline
              fcarney
              wrote on last edited by fcarney
              #12

              Now I tested with minimal project same kit (Arm):

              #include <QCoreApplication>
              #include <QObject>
              
              class TestObj: public QObject
              {
                  Q_OBJECT
              
              public:
                  TestObj(QObject* parent=nullptr){
              
                  }
              
              signals:
                  void doexit(int code);
              };
              
              int main(int argc, char *argv[])
              {
                  QCoreApplication a(argc, argv);
              
                  TestObj testobj;
              
                  QObject::connect(&testobj, &TestObj::doexit, qApp, &QCoreApplication::exit);
                  QObject::connect(&testobj, SIGNAL(doexit()), qApp, SLOT(exit()));
              
                  return a.exec();
              }
              
              #include "main.moc"
              

              No errors at all. So that leads me to believe something in the original arm project is causing this with the arm kit.

              I tried resetting the code model and it seemed to have no effect on the errors.

              C++ is a perfectly valid school of magic.

              1 Reply Last reply
              0
              • fcarneyF Offline
                fcarneyF Offline
                fcarney
                wrote on last edited by
                #13

                I found an error in my kit. The qmake was pointing to a qmake in another directory than the compiler directories. The kits were identical. However, this did not make the errors go away. Now, if I compile it never produces those errors. But if I run qmake it does a lot of thinking and then puts those errors in the log window. The errors around the actual code never go away. I am going to try updating qt creator next. Really baffled as to what I am even looking at.

                C++ is a perfectly valid school of magic.

                kshegunovK 1 Reply Last reply
                0
                • fcarneyF fcarney

                  I found an error in my kit. The qmake was pointing to a qmake in another directory than the compiler directories. The kits were identical. However, this did not make the errors go away. Now, if I compile it never produces those errors. But if I run qmake it does a lot of thinking and then puts those errors in the log window. The errors around the actual code never go away. I am going to try updating qt creator next. Really baffled as to what I am even looking at.

                  kshegunovK Offline
                  kshegunovK Offline
                  kshegunov
                  Moderators
                  wrote on last edited by kshegunov
                  #14

                  @fcarney said in What could cause clang to error, but gcc compiles it anyway?:

                  Really baffled as to what I am even looking at.

                  Open the documentation for Creator and check how to disable the clang code model (I think it was disabling the plugin somewhere in the menus). Report back whether the 'errors' went away.

                  Read and abide by the Qt Code of Conduct

                  1 Reply Last reply
                  0
                  • fcarneyF Offline
                    fcarneyF Offline
                    fcarney
                    wrote on last edited by
                    #15

                    @kshegunov said in What could cause clang to error, but gcc compiles it anyway?:

                    Report back whether the 'errors' went away.

                    The errors are no more. qmake and rebuild.

                    C++ is a perfectly valid school of magic.

                    kshegunovK 1 Reply Last reply
                    0
                    • fcarneyF fcarney

                      @kshegunov said in What could cause clang to error, but gcc compiles it anyway?:

                      Report back whether the 'errors' went away.

                      The errors are no more. qmake and rebuild.

                      kshegunovK Offline
                      kshegunovK Offline
                      kshegunov
                      Moderators
                      wrote on last edited by kshegunov
                      #16

                      If you still want to use it, tweak the flags to suit your need after re-enabling:
                      https://doc.qt.io/qtcreator/creator-clang-codemodel.html

                      Read and abide by the Qt Code of Conduct

                      1 Reply Last reply
                      0
                      • fcarneyF Offline
                        fcarneyF Offline
                        fcarney
                        wrote on last edited by
                        #17

                        How can clang produce errors for one kit on the project, but not produce errors for the same project on another kit? Same exact code. Same exact clang settings. This sounds like to me some temporary file is not getting cleared.

                        C++ is a perfectly valid school of magic.

                        kshegunovK 1 Reply Last reply
                        0
                        • fcarneyF fcarney

                          How can clang produce errors for one kit on the project, but not produce errors for the same project on another kit? Same exact code. Same exact clang settings. This sounds like to me some temporary file is not getting cleared.

                          kshegunovK Offline
                          kshegunovK Offline
                          kshegunov
                          Moderators
                          wrote on last edited by
                          #18

                          Dunno. It shouldn't, but I don't use it because it is fat.

                          Read and abide by the Qt Code of Conduct

                          1 Reply Last reply
                          1
                          • fcarneyF Offline
                            fcarneyF Offline
                            fcarney
                            wrote on last edited by
                            #19

                            I am gonna say this is solved. I am tired of wasting time on this. Thanks for your help everyone.
                            If I figure this out later I will post something here. I am going to be reevaluating my arm compiler installation later. Maybe that will find something.

                            C++ is a perfectly valid school of magic.

                            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 Extensions
                            • Unsolved