for C++ language standard
-
The C++ language standard is specified as $(Qt_STDCPP_), but I'm not sure which version it corresponds to—C++11, C++14, C++17, C++20, or C++23. It seems different from those versions. Can someone who knows well provide more details?"
-
@Teemo-of-LOL you can specify the C++ standard you want to use in your build system (
qmake
orcmake
orqbs
). Qt will adjust to it. -
@sierdzio Yes, that's correct. Although you can specify it separately, in my Qt program, it's indicated as $(Qt_STDCPP_), so I inquired about it. Could it be understood that setting $(Qt_STDCPP_) provides the C++ standard according to the version of Visual Studio?
-
@Teemo-of-LOL said in for C++ language standard:
$(Qt_STDCPP_)
Since this variable is not documented somewhere you should not use them.
-
@Teemo-of-LOL I think you should rather use some documented stuff, like
__cplusplus
: https://learn.microsoft.com/en-us/cpp/build/reference/zc-cplusplus?view=msvc-170It's not documented very well online, but each C++ standard has a well-defined value for
__cplusplus
. -
@Christian-Ehrlicher It seems that using $(Qt_STDCPP_) is not recommended. Why is my program set to $(Qt_STDCPP_) for the C++ language standard? Is it necessary to modify this part? Could you please check this address: https://stackoverflow.com/questions/70373606/how-to-fix-qt-requires-a-c17-compiler? Other users also seem to have set it to $(Qt_STDCPP_)
-
@Christian-Ehrlicher It seems similar to what I found. Link: https://stackoverflow.com/questions/70373606/how-to-fix-qt-requires-a-c17-compiler. Thank you for the detailed explanation. In my case, although I don't encounter errors, it seems I need to reconfigure the C++ standard language setting. Thank you
-
As @sierdzio Already told you use the corresponding cmake and qmake commands to set the language standard. If this does not work for you then provide a minimal, compileable example of the problem.
-
@Christian-Ehrlicher I have a list of C++ language standards, including C++14, C++17, and C++20. I will proceed by changing it to C++20. Thank you for letting me know
-
-
@sierdzio I replied to someone else by mistake. I noticed it late. It seems similar to what I found. Link: https://stackoverflow.com/questions/70373606/how-to-fix-qt-requires-a-c17-compiler. Thank you for the detailed explanation. In my case, although I don't encounter errors, it seems I need to reconfigure the C++ standard language setting. Thank you