Definition of "declare" for Rule 21.2

Moderators: misra-c, david ward

Post Reply
Posts: 7
Joined: Fri Oct 18, 2013 2:31 am
Company: Renesas Solutions Corp.

Definition of "declare" for Rule 21.2

Post by satoshi » Thu Apr 17, 2014 5:22 am

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

Posts: 561
Joined: Thu Jan 05, 2006 1:11 pm

Re: Definition of "declare" for Rule 21.2

Post by misra-c » Tue May 20, 2014 12:53 pm

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.
Posted by and on behalf of
the MISRA C Working Group

Post Reply

Return to “8.21 Standard libraries”