MISRA Discussion Forums

Full Version: Definition of "declare" for Rule 21.2
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Rule's title say "shall not be declared."

C90/C99 use the "declare" for function declarations and variable declarations.
And, macros are used the "define".

Quote:p.167
#define __BUILTIN_sqrt(x) (x) /* Non-compliant */

"example" is a rule violation for the macro definition.
To error the macro definitions could not be a role of rule 21.1?


-----
Best regards,
Satoshi Kawajiri
Rule 21.1 restricts the use of #define and #undef on certain names.
Rule 21.2 restricts the declarations of certain names.

As you found, we have incorrectly put an example in the incorrect rule.

Code:
#define _BUILTIN_sqrt(x) (x)      /* Non-compliant with Rule 21.1, but compliant with Rule 21.2 */

int _BUILTIN_sqrt;                /* Non-compliant with Rule 21.2 */

Thank you for pointing this out to us.