[previous] MISRA C:2012  Rule-8.8:  (Required) [next] The static storage class specifier shall be used in all declarations of objects and functions that have internal linkage

Amplification:

Since definitions are also declarations, this rule applies equally to definitions.

Example Code:


#pragma PRQA_MESSAGES_OFF 3219,3222,3408,3447

#include "misra.h"
#include "m3cmex.h"

static int16_t obj_0808a;                  /*      */   /* Internal linkage */
extern int16_t obj_0808a;                  /* 3224 */   /* Internal linkage */

extern int16_t obj_0808b;                  /*      */   /* External linkage */
       int16_t obj_0808b;                  /*      */   /* External linkage */

       int16_t obj_0808c;                  /*      */   /* External linkage */
extern int16_t obj_0808c;                  /*      */   /* External linkage */

static int16_t obj_0808d;                  /*      */   /* Internal linkage */
       int16_t obj_0808d;                  /* 0625 */   /* External linkage - MISRA Violation - Rule 1.3 */

       int16_t obj_0808e;                  /*      */   /* External linkage */
static int16_t obj_0808e;                  /* 0625 */   /* Internal linkage - MISRA Violation - Rule 1.3 */

extern int16_t obj_0808f;                  /*      */   /* External linkage */
static int16_t obj_0808f;                  /* 0625 */   /* Internal linkage - MISRA Violation - Rule 1.3 */



static int16_t rule_0808a( void );         /*      */   /* Internal linkage */

int16_t rule_0808a( void )
{                                          /* 3224 */   /* Internal linkage */
    extern int16_t a0808;                  /*      */   /* External linkage */
    static int16_t a0808 = 0;              /* 0622 */   /* No       linkage */

    extern int16_t obj_0808a;              /*      */   /* Internal linkage */

    extern int16_t obj_0808b;              /*      */   /* External linkage */

    return 0;
}


QAC messages that encompass this guideline:

3224 This identifier has previously been declared with internal linkage but is not declared here with the static storage class specifier.



(c) The Motor Industry Research Association, 2012
QA C Source Code Analyser 8.1.2
MISRA C:2012 Compliance Module 1.0
© 2013 Programming Research
www.programmingresearch.com
Personality Groups | Glossary | Message Index | MISRA C:2012 Rule Index Contents