![]() |
![]() |
3448 | ![]() |
||||
![]() | |||||||
| Declarations and Definitions | |||||||
It makes sense not to define a typedef in more than one place. If the typedef is used to declare or define an object or function with external linkage, it should be defined in a header file because it can be assumed that the typedef will be required in more than one translation unit. This practice is safer and more maintainable than inserting a local declaration in each source file. Be aware that QAC only recognises a file as being a header file when it is analysed via a #include statement. So, for example, message 3448 will be generated in a ".h" file if the typedef is used in a declaration with external linkage and the file is analysed on its own. For example:
/*PRQA S 2017 ++*/
typedef int TYPE; /* Message 3448 */
extern TYPE foo(void); /* Message 3447 */
extern TYPE foo(void)
{
return 1;
}
MISRA C:2012 Rules applicable to message 3448:
| Rule-5.6 (Required) | A typedef name shall be a unique identifier |
![]() | ||
| 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 |