MISRA Discussion Forums

Full Version: 12.6 for Preprocessor Directives?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Was 12.6 intended to prohibit the use of the '!' operator on such code as
#if ! defined A

Could a case not be made the result of 'defined' is an "effectively Boolean Expression"?
I don't see why you could possibly claim that the defined preprocessing operator is not "effectively Boolean"
ISO 9899:1990 clause 6.8.1 says it return either 0 or 1.
Granted it wil be a long and not an int that a true (or at least as true as you can get in C) Boolean would be.
I don't know hat values you expect Booleans to take!
So I think a strong case can be made.
Exactly, William. :-) I merely was looking for confirmation from MISRA the absence of 'defined' in the definition of "Boolean Expressions" was, perhaps, an oversight.
Rule 12.6 is not intended to prohibit the use of the '!' operator in this way. It can indeed be argued that the 'defined' operator yields an effectively Boolean expression and this is a fair justification for permitting '!' to be applied to the result of 'defined'.