[previous] 1507 [next] 'name' is used as a typedef for different types.
CMA maintenance checks

A typedef name does not have linkage.

When an object or function is declared using a typedef name, it is the underlying type of the typedef that is used for the declaration, a typedef is simply an alias to that type.

As the compiler will not perform any type checking based on the typedef name, reusing a name for different typedef declarations may cause user confusion.

For Example:

// TU1.cpp
typedef void * HANDLE;

void foo (HANDLE);

// TU2.cpp
typedef int * HANDLE;

void foo (HANDLE)
{
}

A user may believe that the function declared in TU1 is defined in TU2, however this is not the case, and the two functions are unrelated.

Where possible, a typedef should be declared once in a header file, and this header file included into every translation unit requiring the typedef declaration. This will ensure that the name declared by the typedef is the same in every translation unit where the typedef is used.

This message is generated whenever an identifier that is used to define a typedef is also used, somewhere else with the project, to define a different typedef.


MISRA C:2012 Rules applicable to message 1507:

Rule-5.6  (Required) A typedef name shall be a unique identifier


See also:

QA·C Source Code Analyser 8.1
MISRA C:2012 Compliance Module 1.0
© 2012 Programming Research.
www.programmingresearch.com
Personality Groups | Glossary | Message Index | MISRA C:2012 Rule Index Contents