Qt Creator and C++14 compatibility on OS X

  • Hi guys. I'm trying to make this:

    void throw_exception(const auto& obj, const QString& errorMsg)
    // .. here my code

    as you can see, I'm using auto as parameter of my function, but this feature is available in c++14. To enable c++14 compilation I have added this 2 lines t my .pro file:

    CONFIG += c++11
    QMAKE_CXXFLAGS += -std=c++1y

    CONFIG += c+=11 and not c++14 because for some reason qt creator doesn't understand CONFIG+= c++14.
    well... this doesn't work. The error which I got is simple:

    ../untitled/mainwindow.h:6:28: error: 'auto' not allowed in function prototype
    void throw_exception(const auto& obj, const QString& errorMsg)

    so, that told me that c++14 configuration is not available, only c++11 is available...
    How can I fix this ?


  • I don't think your function definition is legal C++. You probably want something like:

    template<typename T>
    void throw_exception(T const& obj, QString const& errorMsg) {
       /// ...

    AFAIK only abbreviated generic lambdas allow auto type deduction of function arguments.

  • Thanks.. c++14 has support for auto type in parameters but just in lambda functions... not for free functions, regards... my mistake

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.