Effect of #ifdef on the scan

Hi all,

in C/C++, what is the effect if #ifdef on the scan ? Are “disabled” parts analyzed ?

Thanks

We only analyze the parts that are enabled in the configuration you used to build your code with the build wrapper.

If you want to analyze “disabled” parts too, you can create several projects, each one with a different build configuration. For instance, we use that to analyze the same source code on Linux and Windows.

Thank you for this info :slight_smile:

Won’t creating 2 projects (one for Linux, one for Windows) double the number of lines of code being scanned? That’s not really fair since at least some of the code will be common. In our case, 90% of the code is common.

Yes, you are right.

Usually, the platform specific code is isolated in a dedicated subproject, so you could analyze only this subproject for each platform, and analyze the rest of the code only once. A side effect of this organization is that it avoids creating duplicated issues that you would then have to review for all platforms.

We are aware that this might not be the best experience for all situations, but we currently don’t have a better alternative to propose.