Nominate our 2022 Qt Champions!

Why is Q_DECL_NOEXCEPT macro empty using C++11?

  • I'm using Qt 5.7.1 clang 64. Clang version - Apple LLVM version 8.0.0 (clang-800.0.42.1)
    If I write Q_DECL_NOEXCEPT or Q_DECL_CONSTEXPR macros in my code and follow symbol under cursor (F2) I'm getting:

    # define Q_DECL_CONSTEXPR
    # define Q_DECL_NOEXCEPT

    I thought above macros must be:

    # define Q_DECL_CONSTEXPR constexpr
    # define Q_DECL_NOEXCEPT noexcept

    I put in .pro file such line:
    CONFIG += c++11
    actually it's by default there.

    Could you possibly tell me how I can fix that?

    UPD: And Q_NULLPTR is NULL instead of nullptr. Hmmm...

  • Lifetime Qt Champion


    Check whether Q_COMPILER_NOEXCEPT is defined.

    The compiler detection header is pretty complex so I wouldn't be surprised that you get shown the wrong line.

  • @SGaist

    Hi! No, it isn't defined in my case.

  • Lifetime Qt Champion

    How did you test that ?

    I just checked and its defined properly as it should.

  • @SGaist

    Opened qcompilerdetection.h header file.

    alt text

    I was surprised to see that all C++11 features weren't detected. Hmmm...

  • Moderators

    @Suares Have you actually confirmed that it doesn't get defined during compilation or are you just talking about the colorization in the editor? These can sometimes go out of sync.

  • Lifetime Qt Champion

    Reading a file in an IDE is not a test.

    Like I wrote before, this file does a set of lengthy tests to determine what the compiler is capable of. Qt Creator can't get that in sync with the compiler(s) used to build your project.

  • @Chris-Kawa @SGaist

    I've just checked noexcept, nullptr, ... specifiers instead of Q_DECL_NOEXCEPT, Q_NULLPTR, ... and everything is okay.
    I thought if macros are disabled (without highlighting like in above image) then Qt didn't determine C++ features.

    I think I can mark issue as resolved. Thank you!

Log in to reply