[previous] MISRA C:2012  Rule-5.6:  (Required) [next] A typedef name shall be a unique identifier

Amplification:

A typedef name shall be unique across all name spaces and translation units. Multiple declarations of the same typedef name are only permitted by this rule if the type definition is made in a header file and that header file is included in multiple source files.

Exception:

The typedef name may be the same as the structure, union or enumeration tag name associated with the typedef.

Example Code:


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

typedef int8_t    t0506a;
typedef int16_t   t0506b;
typedef int16_t   t0506c;
typedef int32_t   t0506d;                       /* 3448 */

extern t0506d mheavy;                           /* 3447 */


extern int16_t rule_0506(void)
{
  typedef signed char xs8;

  xs8 scm = 1;

  return scm;
}


QAC messages that encompass this guideline:

1506 The identifier '%1s' is declared as a typedef and is used elsewhere for a different kind of declaration.
1507 '%1s' is used as a typedef for different types.
1508 The typedef '%1s' is declared in more than one location.
3448 Declaration of typedef '%s' is not in a header file although it is used in a definition or declaration with external linkage.



(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