-
-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Update default language standard to the latest standard + feat: Set cppcheck default std instead of defaulting standard based on it #271
Conversation
2b0a70f
to
303b6ea
Compare
C++ fails to use 23 and C fails to use 23,20,17 because cppcheck dosen't support them. Instead of implicitly using an old standard, I think it's fairly reasonable to just use the latest standard while setting cppcheck to use the default standard, and give a Also, the corresponding cppcheck option of --std=<id> Set standard.
The available options are:
* c89
C code is C89 compatible
* c99
C code is C99 compatible
* c11
C code is C11 compatible (default)
* c++03
C++ code is C++03 compatible
* c++11
C++ code is C++11 compatible
* c++14
C++ code is C++14 compatible
* c++17
C++ code is C++17 compatible
* c++20
C++ code is C++20 compatible (default) Versions are hard-coded in the code, as cppcheck runs normally even if I run if(CMAKE_CXX_STANDARD MATCHES [[03|11|14|17|20]])
set(CMAKE_CXX_CPPCHECK ${CMAKE_CXX_CPPCHECK} --std=c++${CMAKE_CXX_STANDARD})
else()
message(${WARNING_MESSAGE} "cppcheck dosen't support specified C++ standard ${CMAKE_CXX_STANDARD}. Using the cppcheck default C++ standard version.")
endif() |
303b6ea
to
d40ef51
Compare
d40ef51
to
ca70709
Compare
This is not required according to [the implementation](https://gitlab.kitware.com/cmake/cmake/-/blob/8733dcd11588f2d9eb0bddc8af8a6db7a2e9eba8/Source/cmcmd.cxx#L370-416).
Is this ready to get merged? Can we address the essential part of my comments, or do you think this will not cause issues? |
@aminya Sorry for the delay. According to my recent attempts, cppcheck itself is unable to detect the version issue, so this is the best result we can achieve at the moment. I believe the current changes are sufficient and ready to merge, and I can manually maintain the version changes afterwards - after all, we were manually adjusting to the latest C++ version before. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the contribution
Update the default
CMAKE_CXX_STANDARD
andCMAKE_C_STANDARD
settings to the latest standard version if they're not specified by the user.Additionally, the standard test code is generalized to a function
_set_language_standard
: