Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Do any other forms of conditional inclusion violate Directive 5.7.2?
#2
Firstly, as stated in your examples, all the statements are compliant, as there are no code statements being commented out.

If there were any code statements between the #if and the #endif, then arguably, they are all non-compliant.

This is one of the rare cases where what we are trying to do depends upon the intent of the programmer - which a checking tool cannot know. The issue is that commenting out code makes the program harder to manually review and may lead to confusion. However, there are occasions when different code is required in different builds of a program - for example when compiling for execution on multiple platforms. It is difficult to specify a rule that prevents the 'bad case' but allows the 'good' - hence why its a directive and not a rule.

What a tool chooses to report against this requirement is really a 'quality of implementation' issue.
For example, a tool might report  "#if 0"  but not  "#if macro0"  where macro0 expands to "0"
Posted by and on behalf of
the MISRA C++ Working Group
Reply


Messages In This Thread
RE: Do any other forms of conditional inclusion violate Directive 5.7.2? - by misra cpp - 27-09-2024, 03:09 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)