Rule 5.6 A ty pedef name shall be a unique identifier

Moderators: misra-c, david ward

Post Reply
xiaoxin
Posts: 2
Joined: Fri Mar 30, 2018 8:12 am
Company: 中国科学院研究所

Rule 5.6 A ty pedef name shall be a unique identifier

Post by xiaoxin » Wed May 09, 2018 8:36 am

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: Select all

void func ( void )
{
	{
		typedef unsigned char u8_t;
	}
}
b.c

Code: Select all

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: Select all

int a =8;
d.c

Code: Select all

void main(){
int a = 9;
}
In other words, whether cross-document considerations are considered。
Looking forward to your reply。

xiaoxin
Posts: 2
Joined: Fri Mar 30, 2018 8:12 am
Company: 中国科学院研究所

Re: Rule 5.6 A ty pedef name shall be a unique identifier

Post by xiaoxin » Fri May 11, 2018 2:42 am

anybody here?

misra-c
Posts: 569
Joined: Thu Jan 05, 2006 1:11 pm

Re: Rule 5.6 A ty pedef name shall be a unique identifier

Post by misra-c » Thu Oct 04, 2018 11:25 am

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

Post Reply

Return to “8.5 Identifers”