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. [SOLVED] C++11 flags get constantly ignored by compiler
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] C++11 flags get constantly ignored by compiler

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 4.4k Views 2 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.
  • D Offline
    D Offline
    developSomething
    wrote on last edited by developSomething
    #1

    Hi,
    i am trying to compile a lib which is written in C++ using c11 features.
    My System is Ubuntu 14.04, QT5.4.1 and g++4.9

    I have tried out all types of flag settings i could find like
    QMAKE_CXXFLAGS += -std=c++11
    or
    CONFIG += c++11
    in the .PRO file, like i found it here on the forum
    everything gets ignored and the same build error comes up:
    error: 'for' loop initial declarations are only allowed in C99 or C11 mode
    use option -std=c99, -std=gnu99, -std=c11 or -std=gnu11 to compile your code

    Anybody any hint?

    K 1 Reply Last reply
    0
    • D developSomething

      Hi,
      i am trying to compile a lib which is written in C++ using c11 features.
      My System is Ubuntu 14.04, QT5.4.1 and g++4.9

      I have tried out all types of flag settings i could find like
      QMAKE_CXXFLAGS += -std=c++11
      or
      CONFIG += c++11
      in the .PRO file, like i found it here on the forum
      everything gets ignored and the same build error comes up:
      error: 'for' loop initial declarations are only allowed in C99 or C11 mode
      use option -std=c99, -std=gnu99, -std=c11 or -std=gnu11 to compile your code

      Anybody any hint?

      K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      @developSomething
      Did you rerun qmake in Qt creator?
      Sometimes this helps.

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0
      • B Offline
        B Offline
        BOBOS
        wrote on last edited by
        #3

        I had a similar problem. I was getting this #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options. when i added a library to my project. A couple of hours later i saw your post and went to /opt/Qt5.4.1/5.4/gcc_64/mkspecs/linux-g++ and chenged qmake.conf, replaced the line CONFIG += incremental with this line CONFIG += c++11 incremental and then surprise, it workd.But still i get a litle warning: libGL error: failed to load driver: swrast dunno what's that about but my program warks fine. Im running linux mint 64 bit. Hope it helps.

        1 Reply Last reply
        0
        • D Offline
          D Offline
          developSomething
          wrote on last edited by
          #4

          I found out that all compiler settings get ignored as long as the source files have the *.c extension.
          So renaming all files to cpp was the solution

          K 1 Reply Last reply
          0
          • D developSomething

            I found out that all compiler settings get ignored as long as the source files have the *.c extension.
            So renaming all files to cpp was the solution

            K Offline
            K Offline
            koahnig
            wrote on last edited by
            #5

            @developSomething
            Most compilers are using the file extension to detect the programming language. Probably a result of several stages of language detection. Because you must have C++ statements in a C. I thought the compiler would complain with a different warning at least.

            Also it was asking for C11 mode. This seems to be for C. While you were trying to apply c++11, this is for C++11.

            Vote the answer(s) that helped you to solve your issue(s)

            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