[previous] MISRA-C:2004  Rule  19.14:  (Required) [next] The defined preprocessor operator shall only be used in one of the two standard forms.
The only two permissible forms for the defined preprocessor operator are:

    defined( identifier )
    defined identifier

Any other form leads to undefined behaviour, for example:

#if defined( X > Y )          /* not compliant - undefined behaviour */

Generation of the token defined during expansion of a #if or #elif preprocessing directive also leads to undefined behaviour and shall be avoided, for example:

#define DEFINED defined
#if DEFINED( X )              /* not compliant - undefined behaviour */


QAC messages that encompass this guideline:

0885 [U] The token 'defined' is generated in the expansion of this macro.
0887 [U] Use of 'defined' must match either 'defined(identifier)' or 'defined identifier'.
0888 [U] 'defined' requires an identifier as an argument.


Related rules:

Rule  1.2 No reliance shall be placed on undefined or unspecified behaviour.



(c) The Motor Industry Research Association, 2004
QA C Source Code Analyser 8.1.2
MISRA-C:2004 Compliance Module 3.2
© 2013 Programming Research
www.programmingresearch.com
Personality Groups | Glossary | Message Index | MISRA-C:2004 Rule Index Contents