Page 1 of 1

Definition of "declare" for Rule 21.2

Posted: Thu Apr 17, 2014 5:22 am
by satoshi
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".
#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

Re: Definition of "declare" for Rule 21.2

Posted: Tue May 20, 2014 12:53 pm
by misra-c
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: Select all

#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.