Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule 5.6 A ty pedef name shall be a unique identifier
#1
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。
<t></t>
#2
anybody here?
<t></t>
#3
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.
Posted by and on behalf of the MISRA C Working Group


Forum Jump:


Users browsing this thread: 1 Guest(s)