Compiler configuration is a problem with static analysis tools. In the past, a static analysis (or source code analysis) tool simply worked by pointing it at the source code and hitting “go”. Now it is very different. Without a complete understanding of the software build, including the compiler specifics, you will get inaccurate results.
Under the covers, do you really know what is happening with your compiler? Not usually. You make changes to your code, call your compiler or build command to compile your code, and then fix the issues. Rinse and repeat.
But what is really important for static analysis tools, is that the compiler contains some crucial information to successfully compile your code. Namely, the internal compiler includes and defines. Static analysis tools must generate this data, otherwise they won’t know where the system includes and defines are coming from for your specific compiler. Hence, the static analysis results are about as accurate as the weather man’s weekly prediction.
Luckily most compilers have a way to capture this. For example to find out the defines and includes from gcc:
gcc -E -dM dummy.c gcc -E -Wp,-v dummy.c
Where dummy.c is just an empty file. This will give you a dump of all the defines and includes, respectively. Now, when static analysis tools build their data they have a mapping of the proper defines and includes for your specific compiler and everyone is happy.
In the past, it seemed like a good idea to make compiler configuration extensible. This meant that static analysis tools could support any compiler if you didn’t mind taking the time to build that support. It wasn’t usually very complex but it could be prone to errors. Instead, it makes more sense to just provide the support right out of the box, so taking the words from the late Steve Jobs: “it just works“. As long as static analysis tools have an extensible interface, these tools should be able to support new and obscure compilers very quickly. Make sure your static analysis vendor has support for your specific compiler that you use, and if they don’t they better turn that around in a snap.