![]() |
![]() |
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.
See also:
![]() | ||
| QA·C Source Code Analyser 8.1.2
© 2013 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | Contents |