Rule 8.11(req) - Clarification required

6.8 Declarations and Definitions

Moderators: misra-c, david ward

Locked
Hammer
Posts: 9
Joined: Thu Mar 30, 2006 1:45 pm

Rule 8.11(req) - Clarification required

Post by Hammer » Mon Jul 10, 2006 1:46 pm

Dear Misra

I seek clarification on the particular meaning of this rule. From the rule statment I take it that everything declared at file scope and only used internally should have the static storage class specifier applied.

For example the following would be a violation, ignoring the violation of rule 8.7.

Code: Select all

int32_t var=0; /*VIOLATION, static should be applied*/

int32_t main(void)
{
var++;
return(var);
}
however I take a different meaning from the additional description given. I feel it is more related to the mixing use of extern and static.

Code: Select all


extern int32_t var1;
static int32_t var1=0; /*Violation??*/

I would like to know which violation represents the meaning of this rule.

misra-c
Posts: 556
Joined: Thu Jan 05, 2006 1:11 pm

Post by misra-c » Wed Aug 23, 2006 11:54 am

MISRA-C meeting 23-8-2006

Code: Select all

int32_t var=0; /*VIOLATION, static should be applied*/ 

int32_t main(void) 
{ 
var++; 
return(var); 
}


We agree - this violates 8.10 only.

Code: Select all

extern int32_t var1; 
static int32_t var1=0; /*Violation 8.11*/
This violates 8.11.
---
Posted by and on behalf of
the MISRA C Working Group

Locked

Return to “6.8 Declarations and Definitions”