Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
12.6 for Preprocessor Directives?
#1
Was 12.6 intended to prohibit the use of the '!' operator on such code as
Code:
#if ! defined A
#endif
?

Could a case not be made the result of 'defined' is an "effectively Boolean Expression"?
Reply
#2
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.
<t></t>
Reply
#3
Exactly, William. :-) I merely was looking for confirmation from MISRA the absence of 'defined' in the definition of "Boolean Expressions" was, perhaps, an oversight.
Reply
#4
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'.
Posted by and on behalf of the MISRA C Working Group
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)