Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. With qmake, how to compile moc files with different compiler options?
Forum Updated to NodeBB v4.3 + New Features

With qmake, how to compile moc files with different compiler options?

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
qmakemocgcc
3 Posts 2 Posters 912 Views
  • 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.
  • D Offline
    D Offline
    dave2
    wrote on last edited by
    #1

    In our Qt project, we use gcc option -Wuseless-cast, and we treat warnings as errors (-Werror).

    When gcc compiles C++ files generated by moc (say, moc_foo.cpp), -Wuseless-cast generates warnings (and thus errors):

    moc_foo.cpp: In static member function ‘static void Foo::qt_static_metacall(QObject*, QMetaObject::Call, int, void**)’:
    moc_foo.cpp:78:84: error: useless cast to type ‘_t {aka void (Foo::*)() const}’ [-Werror=useless-cast]
                 if (*reinterpret_cast<_t *>(_a[1]) == static_cast<_t>(&Foo::bar)) {
    

    How could we instruct qmake to pass option -Wno-useless-cast to gcc when compiling modules generated by moc?

    We use Qt 5.12 and gcc 7.5.

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      You can't. See e.g. https://bugreports.qt.io/browse/QTBUG-71938 and feel free to provide a patch for it.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      2
      • D Offline
        D Offline
        dave2
        wrote on last edited by
        #3

        :( but thanks for the links.

        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