#This script is designed to run with Understand - CodeCheck use base ("Understand::Codecheck"); use strict; use constant ERR1 => 'Macro %1 is defined within a block'; use constant ERR2 => 'Macro %1 is undefined within a block'; sub register_tr_text() { my $check = shift; $check->add_tr_text(ERR1); $check->add_tr_text(ERR2); } sub name { return "Macros shall not be #define'd or #undef'd within a block";} sub description { return "Macros shall not be #define'd or #undef'd within a block";} sub detailed_description { return <<"END_DESC"
Rationale
While it is legal to place #define or #undef directives anywhere in a code file, placing them
inside blocks is misleading as it implies a scope restricted to that block, which is not the case.
Normally, #define and #undef directives will be placed near the start of a file, before the first function definition.