I’m developing a piece of C++ firmware to run on a C2000 processor, but I’m also cross-compiling for Visual Studio 2019 so I can run unit tests and get code coverage metrics.
When SonarQube runs against the C2000 build it correctly picks up C++03 from the compiler, and has suggestions relevant to the C++03 features of the language.
When SonarQube runs against the Visual Studio 2019 build, it insists in analyzing the source code with C++11/14 suggestions totally unsuitable for the code-base. Visual Studio 2019 cannot be set for any version earlier than C++14, but that’s fine because we’re just not using newer features.
Linux only recently jumped from C89 to C11 despite GCC having C17 support for ages. Godot limits itself to C++03 despite building on Visual Studio 2019. There are many reasons for a project to limit itself to older language revisions to ensure portability. It would be really useful if SonarQube could be told what revision of the language so a project doesn’t get innundated with language suggestions it’s not able to take.
Yes, we have an option to do that. We keep it private to understand the users’ needs for it before making it public for everyone. I will reach out to you privately with the option; if others have similar or different situations where they need this option, feel free to comment.
We added the following option, that you can use( It should show up in the documentation once a bug is fixed)
Targeted C++ standard
The analyzer targets a specific version of the C++ language to tune the rules in the activated quality profile. This reporting standard is used to:
- Suppress rules that cannot be applied. For example, rules that suggest using
c++20 features while the code is compiled with
- Adjust rules’ messages to suggest the proper fix according to the used standard. For example, a rule that suggest using
c++20 will be tuned to suggest using
std::any_of with older standard.
By default, the reporting standard version is the version that is used to compile the code. This is ideal for most projects. However, there are some edge cases where there is a need to use a reporting standard that is different from the compilation standard. For this reason, we provide the following scanner property to adjust the reporting standard:
This property is only recommended to be used in the case where a project has to comply with a standard older than the one it is compiled with. This can happen if:
- The compiler doesn’t allow to set a specific standard. For example, MSVC doesn’t allow specifying a standard older than
- The project wants to be compiled with the latest standard while still being compliant with an older standard.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.