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. Qt Creator and C++14 compatibility on OS X
Forum Updated to NodeBB v4.3 + New Features

Qt Creator and C++14 compatibility on OS X

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 1.2k Views 1 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.
  • freddy311082F Offline
    freddy311082F Offline
    freddy311082
    wrote on last edited by A Former User
    #1

    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 ?

    regards

    1 Reply Last reply
    0
    • B Offline
      B Offline
      bsomervi
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • freddy311082F Offline
        freddy311082F Offline
        freddy311082
        wrote on last edited by
        #3

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

        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