MISRAC2012-Rule-5.6
In this section:
Synopsis
(Required) A typedef name shall be a unique identifier.
Enabled by default
Yes
Severity/Certainty
Low/Medium

Full description
A typedef with this name has already been declared. This check is identical to MISRAC2004-5.3, MISRAC++2008-2-10-3.
This is a link analysis check.
Coding standards
- MISRA C:2004 5.3
(Required) A typedef name shall be a unique identifier.
- MISRA C:2012 Rule-5.6
(Required) A typedef name shall be a unique identifier
- MISRA C++ 2008 2-10-3
(Required) A typedef name (including qualification, if any) shall be a unique identifier.
Code examples
The following code example fails the check and will give a warning:
typedef int WIDTH;
void f1()
{
WIDTH w1;
}
void f2()
{
typedef float WIDTH;
WIDTH w2;
WIDTH w3;
}
The following code example passes the check and will not give a warning about this issue:
namespace NS1
{
typedef int WIDTH;
}
// f2.cc
namespace NS2
{
typedef float WIDTH; // Compliant - NS2::WIDTH is not the same as NS1::WIDTH
}
NS1::WIDTH w1;
NS2::WIDTH w2;