I have the following code:
Code: Select all
cfg.h: /* uncomment next line if the feature is needed for your project */ /* #define activate_feature */ ----- feature.h: #ifdef activate_feature #ifdef protected_feature /* limited visibility stuff */ [...] #endif /* protected feature */ #endif /* activate feature */ ----- feature.c: #define protected_feature #include "cfg.h" #include "feature.h" #ifdef activate_feature [...] #endif /* activate feature */
Based on each project a different version of cfg.h is used which configures the project specific needs.
In projects where activate_feature is not defined I always got a claim from my code checking tool that the macro protected_feature is not used.
Is this really a violation of Rule 2.5 or is the code checker wrong?
If it is a violation how to handle code where parts a selected by conditional compiling?