![]() |
![]() |
1506 | ![]() |
||||
![]() | |||||||
| 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 both a typedef declaration and a different kind of declaration may cause user confusion. Example:
// TU1.cpp
typedef void * HANDLE;
void foo (HANDLE);
// TU2.cpp
struct HANDLE
{
// ...
};
void foo (HANDLE)
{
}
It may appear 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, anywhere else with the project, for a different kind of declaration.
See also:
![]() | ||
| QA·C Source Code Analyser 8.1.2
© 2013 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | Contents |