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. Compiler ignoring std option for C files (only works on c++ files)
QtWS25 Last Chance

Compiler ignoring std option for C files (only works on c++ files)

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 601 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.
  • ocgltdO Offline
    ocgltdO Offline
    ocgltd
    wrote on last edited by
    #1

    I have a project which mixes some older C and newer C++ files. I have set CONFIG=c++14 in my pro file. And interestingly the whole project compiles fine under Fedora 34.

    However, on CentOS 7 the C files fail to compile (cause is variables declared in for loop). I confirmed that on CentOS 7 the compiler g++ has -std=gnu++1y option for my C++ files, and gcc (with no std option) for C files. So I assume it's using the oldest C standard by default.

    How can I tell my qmake file to to use a later std option for my C files? (like std c99 or gnu99 or whatever is most recent)

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on last edited by ChrisW67
      #5

      The default CentOS 7 GCC versions is 4.8.5 IIRC. C language support is c90 and c95 (complete), and incomplete c99 and c11 support. You might have something more recent.

      If the CONFIG option above does not work then you could manually add the flag to QMAKE_CFLAGS (but not QMAKE_CXXFLAGS). You can find the necessary switch details https://gcc.gnu.org/onlinedocs/gcc-4.8.5/gcc/Standards.html#Standards

      ocgltdO 1 Reply Last reply
      0
      • jeremy_kJ Offline
        jeremy_kJ Offline
        jeremy_k
        wrote on last edited by
        #2

        The qmake variable reference lists c99 and c11 values for CONFIG.

        Asking a question about code? http://eel.is/iso-c++/testcase/

        ocgltdO 1 Reply Last reply
        1
        • jeremy_kJ jeremy_k

          The qmake variable reference lists c99 and c11 values for CONFIG.

          ocgltdO Offline
          ocgltdO Offline
          ocgltd
          wrote on last edited by
          #3

          @jeremy_k I googled for an example but couldn't find one, but are you saying

          CONFIG += c++14 c11
          

          is the solution ? I have been chasing QMAKE_CFLAG or similar

          1 Reply Last reply
          0
          • jeremy_kJ Offline
            jeremy_kJ Offline
            jeremy_k
            wrote on last edited by
            #4

            Try it and come back with the result. The build will give you an answer in less time than any message board.

            Asking a question about code? http://eel.is/iso-c++/testcase/

            1 Reply Last reply
            0
            • C Offline
              C Offline
              ChrisW67
              wrote on last edited by ChrisW67
              #5

              The default CentOS 7 GCC versions is 4.8.5 IIRC. C language support is c90 and c95 (complete), and incomplete c99 and c11 support. You might have something more recent.

              If the CONFIG option above does not work then you could manually add the flag to QMAKE_CFLAGS (but not QMAKE_CXXFLAGS). You can find the necessary switch details https://gcc.gnu.org/onlinedocs/gcc-4.8.5/gcc/Standards.html#Standards

              ocgltdO 1 Reply Last reply
              0
              • C ChrisW67

                The default CentOS 7 GCC versions is 4.8.5 IIRC. C language support is c90 and c95 (complete), and incomplete c99 and c11 support. You might have something more recent.

                If the CONFIG option above does not work then you could manually add the flag to QMAKE_CFLAGS (but not QMAKE_CXXFLAGS). You can find the necessary switch details https://gcc.gnu.org/onlinedocs/gcc-4.8.5/gcc/Standards.html#Standards

                ocgltdO Offline
                ocgltdO Offline
                ocgltd
                wrote on last edited by
                #6

                @ChrisW67 I got it working with QMAKE_CFLAG setting to c11

                Not sure what I compiles fine in some distro without this, but at least this is the solution for others

                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