MISRA Discussion Forums

Full Version: Rule 5.6 A ty pedef name shall be a unique identifier
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
My doubt about this rule is if they violate rules in different files, as follows.If they violate the rules in the same project.
a.c
Code:
void func ( void )
{
    {
        typedef unsigned char u8_t;
    }
}
b.c
Code:
void func ( void )
{
    typedef unsigned char u8_t;
    â€¦â€¦
    
}
Similarly, there are rules 5.3 : An identifi er declared in an inner scope shall not hide an identifier declared in an outer scope
c.c
Code:
int a =8;
d.c
Code:
void main(){
int a = 9;
}
In other words, whether cross-document considerations are considered。
Looking forward to your reply。
anybody here?
Each of the MISRA C:2012 rules has an analysis scope which applies to them. This is described in section 6.6 of the document.

Rule 5.3 has the analysis scope of "Single Translation Unit". This means that each .c file and its associated header files are looked at on their own. When looking a file "d.c", the file "c.c" is not considered and therefore there is no violation of rule 5.3. However, it is a violation of rule 5.8 which requires objects with external linkage to be unique across the "System" of files.

Rule 5.6 has the analysis scope of "System", which means that files "a.c" and "b.c" should be considered together. The example will violate rule 5.6.