![]() |
![]() |
0842 | ![]() |
||||
![]() | |||||||
| Preprocessing | REFERENCE - ISO:C90-6.8.3.5 Scope of Macro Definitions | ||||||
A macro is being #define'd or #undef'd within the scope of a function. It is quite legal to place #define and #undef directives anywhere in source code because macros are not subject to scoping rules like other identifiers. A macro definition is effective only following the point of definition in the source code. However it can be considered good practice to use #define and #undef directives only at the top of a source file (i.e. at file scope) to avoid any possible confusion. For example:
/*PRQA S 2017,3205,3408 ++*/
extern void foo( void )
{
#define M1 10 /* Message 0842 */
int x = M1;
/* ... */
#undef M1 /* Message 0842 and 0841 */
/* ... */
}
No MISRA C:2012 Rules applicable to message 0842
![]() | ||
| QA·C Source Code Analyser 8.1
MISRA C:2012 Compliance Module 1.0 © 2012 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | MISRA C:2012 Rule Index | Contents |