Details
-
Bug
-
Resolution: Done
-
P2: Important
-
5.15.2, 5.15.5, 6.1.2
Description
Seems like there is no way to specify C standard for Visual Studio 2019 project (supported since 16.8).
- As expected, CONFIG += c11 does not work.
- QMAKE_CFLAGS += -std:c11 does not work — QMAKE_CFLAGS just ignored.
- QMAKE_CXXFLAGS += -std:c11 causes error for C++ sources:
cl : command line error D8016: '/std:c++17' and '/std:c11' command-line options are incompatible
I roughly know how to add support of this options to qmake at sources level (possible patch attached), but have no idea how it should be implement at another levels for automatically set flags when CONFIG contains c11 or c17.
Guess it should start with something like that in msvc-version.conf:
greaterThan(QMAKE_MSC_VER, 1927) { # Visual Studio 2019 (16.8) / Visual C++ 19.28 and up QMAKE_CFLAGS_C11 = -std:c11 QMAKE_CFLAGS_C17 = -std:c17 }
UPDATE:
qmake still does not work correctly with attached patch because moc_predefs.h generation calls cl.exe with raw QMAKE_CXXFLAGS (with incompatible -std:c++xx and -std:cxx flags). It looks like it's time to start use QMAKE_CFLAGS for MSVC.
As workaround, I move -std:cxx options from QMAKE_CXXFLAGS to QMAKE_CFLAGS and add QMAKE_CFLAGS parsing to VcprojGenerator. It works for me, but I'm not sure that this is the good solution.
Index: qmake/generators/win32/msvc_vcproj.cpp <+>UTF-8 =================================================================== diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp --- a/qmake/generators/win32/msvc_vcproj.cpp (revision 98e7a6ae2cc1c44ef7ef801ad3149f7a49b3c8fc) +++ b/qmake/generators/win32/msvc_vcproj.cpp (date 1607630120013) @@ -1075,6 +1075,7 @@ } conf.compiler.parseOptions(project->values("QMAKE_CXXFLAGS")); + conf.compiler.parseOptions(project->values("QMAKE_CFLAGS")); if (project->isActiveConfig("windows")) conf.compiler.PreprocessorDefinitions += "_WINDOWS";
Attachments
Issue Links
- relates to
-
QTBUG-96026 Add support for selecting the C18/C17 C language standard
- Closed