Compiler ignoring std option for C files (only works on c++ files)
-
wrote on 21 Aug 2021, 01:02 last edited by
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)
-
wrote on 22 Aug 2021, 02:09 last edited by 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
-
wrote on 21 Aug 2021, 06:56 last edited by
The qmake variable reference lists c99 and c11 values for CONFIG.
-
The qmake variable reference lists c99 and c11 values for CONFIG.
-
wrote on 21 Aug 2021, 18:06 last edited by
Try it and come back with the result. The build will give you an answer in less time than any message board.
-
wrote on 22 Aug 2021, 02:09 last edited by 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
-
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
1/6