![]() |
![]() |
1508 | ![]() |
||||
![]() | |||||||
| 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 declarations (even a typedef to the same type) may cause user confusion. Example:
// header.h
typedef void * HANDLE;
// TU1.cpp
#include "header.h"
void foo (HANDLE);
// TU2.cpp
#include "header.h"
void foo (HANDLE)
{
}
The definition of function foo in TU2 does define the function
declared in TU1.
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 the same typedef is defined in more
than one place.
MISRA C:2012 Rules applicable to message 1508:
| 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 |