<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/">
	<channel>
		<title><![CDATA[MISRA Discussion Forums - 6.5 Identifiers]]></title>
		<link>https://forum.misra.org.uk/</link>
		<description><![CDATA[MISRA Discussion Forums - https://forum.misra.org.uk]]></description>
		<pubDate>Thu, 05 Nov 2026 15:12:57 +0000</pubDate>
		<generator>MyBB</generator>
		<item>
			<title><![CDATA[Rule 5.2 : confusion]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1402</link>
			<pubDate>Thu, 01 Mar 2018 16:08:43 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=4977">ankitshah413</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1402</guid>
			<description><![CDATA[Hello,<br />
<br />
I am getting MISRA 5.2 rule violation in my project. The code for which i am getting violation is a structure that is declared as extern in one header file. The code example is as under<br />
<br />
1.h<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>extern struct con tmp_ev;</code></div></div><br />
2.c<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>struct con tmp_ev;<br />
cioF_get(&amp;tmp_ev);</code></div></div><br />
3.c<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>struct con tmp_ev;<br />
 (void)eeF_read(CON, &amp;tmp_ev);</code></div></div><br />
I get the warning only in 2.c in the line struct con tmp_ev; saying that declaration of symbol tmp_ev hides symbol tmp_ev and not in 3.c . Both 2.c and 3.c include the 1.h header file.<br />
<br />
I am confused why this issue is present. Can anyone help me resolve this issue?<br />
<br />
Thank you]]></description>
			<content:encoded><![CDATA[Hello,<br />
<br />
I am getting MISRA 5.2 rule violation in my project. The code for which i am getting violation is a structure that is declared as extern in one header file. The code example is as under<br />
<br />
1.h<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>extern struct con tmp_ev;</code></div></div><br />
2.c<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>struct con tmp_ev;<br />
cioF_get(&amp;tmp_ev);</code></div></div><br />
3.c<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>struct con tmp_ev;<br />
 (void)eeF_read(CON, &amp;tmp_ev);</code></div></div><br />
I get the warning only in 2.c in the line struct con tmp_ev; saying that declaration of symbol tmp_ev hides symbol tmp_ev and not in 3.c . Both 2.c and 3.c include the 1.h header file.<br />
<br />
I am confused why this issue is present. Can anyone help me resolve this issue?<br />
<br />
Thank you]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[MISRA C 2004 rule 5.2 vioated on pointer as argument]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1061</link>
			<pubDate>Thu, 05 Jun 2014 16:32:47 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=3371">Newmerlin</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1061</guid>
			<description><![CDATA[I have a customer for our compiler who is asking this question:<br />
<br />
Rule 5.2 deals with identifiers declared with block scope that hide identifiers declared at an outer block, or file, scope. It does not apply to identifiers declared in other translation units. <br />
<br />
    extern void SerialMaster_task(void *p_arg);<br />
<br />
Warning[Pm017]: symbol hides parameter "p_arg" (declared at line 380) - identifiers in an inner scope shall not use the same name as an identifier in an outer scope, and therefore hide the identifier (MISRA C 2004 rule 5.2)<br />
<br />
A parameter in the *declaration* of an external subroutine does not define a symbol in the current context.<br />
<br />
---<br />
Can you elaborate about why the source line above invokes MISRA C 2004 rule 5.2?<br />
<br />
Dave Bailey<br />
IAR Systems]]></description>
			<content:encoded><![CDATA[I have a customer for our compiler who is asking this question:<br />
<br />
Rule 5.2 deals with identifiers declared with block scope that hide identifiers declared at an outer block, or file, scope. It does not apply to identifiers declared in other translation units. <br />
<br />
    extern void SerialMaster_task(void *p_arg);<br />
<br />
Warning[Pm017]: symbol hides parameter "p_arg" (declared at line 380) - identifiers in an inner scope shall not use the same name as an identifier in an outer scope, and therefore hide the identifier (MISRA C 2004 rule 5.2)<br />
<br />
A parameter in the *declaration* of an external subroutine does not define a symbol in the current context.<br />
<br />
---<br />
Can you elaborate about why the source line above invokes MISRA C 2004 rule 5.2?<br />
<br />
Dave Bailey<br />
IAR Systems]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rule #5.1 clarification]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=926</link>
			<pubDate>Mon, 10 Dec 2012 15:49:20 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=64">gs</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=926</guid>
			<description><![CDATA[Hi,<br />
    The conversation at <a href="http://www.misra.org.uk/forum/viewtopic.php?f=61&amp;t=508" target="_blank" rel="noopener" class="mycode_url">http://www.misra.org.uk/forum/viewtopic.php?f=61&amp;t=508</a> states identifiers longer than 31 characters are permitted. However, the exemplar suite suggest such identifiers are, per se, prohibited. Which is correct?]]></description>
			<content:encoded><![CDATA[Hi,<br />
    The conversation at <a href="http://www.misra.org.uk/forum/viewtopic.php?f=61&amp;t=508" target="_blank" rel="noopener" class="mycode_url">http://www.misra.org.uk/forum/viewtopic.php?f=61&amp;t=508</a> states identifiers longer than 31 characters are permitted. However, the exemplar suite suggest such identifiers are, per se, prohibited. Which is correct?]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rule 5.5 and local static variables]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=865</link>
			<pubDate>Wed, 16 Nov 2011 12:43:42 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=368">pkruk</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=865</guid>
			<description><![CDATA[Hello, <br />
<br />
I wanted to confirm if having local static variables with the same name in different functions is not compliant with rule 5.5.<br />
For example:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>void foo1() {<br />
&nbsp;&nbsp;&nbsp;&nbsp;static int x1 = 0; /* Not compliant - foo1, foo2 */<br />
&nbsp;&nbsp;&nbsp;&nbsp;static int x2 = 0; /* Not compliant - foo1, foo2 */<br />
}<br />
void foo2() {<br />
&nbsp;&nbsp;&nbsp;&nbsp;static int x1 = 0; /* Not compilant - foo1, foo2 */<br />
&nbsp;&nbsp;&nbsp;&nbsp;int x2;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* Not compliant - foo1, foo2 */<br />
&nbsp;&nbsp;&nbsp;&nbsp;int x3;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* Not compliant - global, foo2 */<br />
}<br />
extern int x3; /* Not compliant - global, foo2 */</code></div></div><br />
This is similar to <a href="http://www.misra-c.com/forum/viewtopic.php?f=61&amp;t=812" target="_blank" rel="noopener" class="mycode_url">http://www.misra-c.com/forum/viewtopic.php?f=61&amp;t=812</a> and <a href="http://www.misra-c.com/forum/viewtopic.php?f=61&amp;t=962#p1807" target="_blank" rel="noopener" class="mycode_url">http://www.misra-c.com/forum/viewtopic.p...=962#p1807</a> but I just wanted a clear confirmation.<br />
<br />
Thanks]]></description>
			<content:encoded><![CDATA[Hello, <br />
<br />
I wanted to confirm if having local static variables with the same name in different functions is not compliant with rule 5.5.<br />
For example:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>void foo1() {<br />
&nbsp;&nbsp;&nbsp;&nbsp;static int x1 = 0; /* Not compliant - foo1, foo2 */<br />
&nbsp;&nbsp;&nbsp;&nbsp;static int x2 = 0; /* Not compliant - foo1, foo2 */<br />
}<br />
void foo2() {<br />
&nbsp;&nbsp;&nbsp;&nbsp;static int x1 = 0; /* Not compilant - foo1, foo2 */<br />
&nbsp;&nbsp;&nbsp;&nbsp;int x2;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* Not compliant - foo1, foo2 */<br />
&nbsp;&nbsp;&nbsp;&nbsp;int x3;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* Not compliant - global, foo2 */<br />
}<br />
extern int x3; /* Not compliant - global, foo2 */</code></div></div><br />
This is similar to <a href="http://www.misra-c.com/forum/viewtopic.php?f=61&amp;t=812" target="_blank" rel="noopener" class="mycode_url">http://www.misra-c.com/forum/viewtopic.php?f=61&amp;t=812</a> and <a href="http://www.misra-c.com/forum/viewtopic.php?f=61&amp;t=962#p1807" target="_blank" rel="noopener" class="mycode_url">http://www.misra-c.com/forum/viewtopic.p...=962#p1807</a> but I just wanted a clear confirmation.<br />
<br />
Thanks]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rule 5.2, at what scope is the rule broken?]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=796</link>
			<pubDate>Mon, 06 Dec 2010 14:33:19 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=632">joa07</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=796</guid>
			<description><![CDATA[Hello!<br />
<br />
Rule 5.2 says that an identifier in a inner scope shall not hide an identifier in an outer scope.<br />
I have two cases where I'm not sure what the rule says.<br />
<br />
1. May a function use the name of an identifier that is local for this translation unit, but may be extern global for another translation unit? The first translation unit does not know this identifier at compile-time, so this error should only be detectable at link-time.<br />
<br />
2. If the first question was a Yes, does this following code break this rule (it may brake some other Misra rules)?<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>int func1(void) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;int var = 23;<br />
&nbsp;&nbsp;&nbsp;&nbsp;return var;<br />
}<br />
<br />
extern double var;&nbsp;&nbsp;&nbsp;&nbsp;/* The name is reused here, global scope. Probably breaks rule 8.8 */<br />
<br />
double func2(void) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;return var;<br />
}</code></div></div>]]></description>
			<content:encoded><![CDATA[Hello!<br />
<br />
Rule 5.2 says that an identifier in a inner scope shall not hide an identifier in an outer scope.<br />
I have two cases where I'm not sure what the rule says.<br />
<br />
1. May a function use the name of an identifier that is local for this translation unit, but may be extern global for another translation unit? The first translation unit does not know this identifier at compile-time, so this error should only be detectable at link-time.<br />
<br />
2. If the first question was a Yes, does this following code break this rule (it may brake some other Misra rules)?<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>int func1(void) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;int var = 23;<br />
&nbsp;&nbsp;&nbsp;&nbsp;return var;<br />
}<br />
<br />
extern double var;&nbsp;&nbsp;&nbsp;&nbsp;/* The name is reused here, global scope. Probably breaks rule 8.8 */<br />
<br />
double func2(void) {<br />
&nbsp;&nbsp;&nbsp;&nbsp;return var;<br />
}</code></div></div>]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rule 5.5 and unused extern declarations]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=661</link>
			<pubDate>Wed, 03 Jun 2009 12:30:24 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=606">roberto</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=661</guid>
			<description><![CDATA[Suppose file f.c contains<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>extern int a;<br />
extern int f(int x);</code></div></div>but never defines or references that externally-declared identifiers.<br />
Suppose also that the whole program is constituted by f.c and g.c, where g.c contains<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>static int a = 3;<br />
static int f(int x) {<br />
&nbsp;&nbsp;return x+a;<br />
}</code></div></div>Note that there are no other files in the program and that the program is valid C.<br />
In particular, no compilation unit defines or uses the identifiers declared in f.c.<br />
<br />
Is this code violating rule 5.5?<br />
Thanks,<br />
<br />
   Roberto]]></description>
			<content:encoded><![CDATA[Suppose file f.c contains<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>extern int a;<br />
extern int f(int x);</code></div></div>but never defines or references that externally-declared identifiers.<br />
Suppose also that the whole program is constituted by f.c and g.c, where g.c contains<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>static int a = 3;<br />
static int f(int x) {<br />
&nbsp;&nbsp;return x+a;<br />
}</code></div></div>Note that there are no other files in the program and that the program is valid C.<br />
In particular, no compilation unit defines or uses the identifiers declared in f.c.<br />
<br />
Is this code violating rule 5.5?<br />
Thanks,<br />
<br />
   Roberto]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[A signed bit field of 1 bit length is not useful]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=622</link>
			<pubDate>Sun, 08 Feb 2009 08:41:45 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=286">JonM</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=622</guid>
			<description><![CDATA[Is it possible to improve Rule 6.5 "A signed bit field of 1 bit length is not useful". Unlike the other rules, this doesn't actually advise/recommend any behaviour or give any insight as to what compilers may or may not do when presented with this.<br />
<br />
How about - following the same outline structure of the following rule 7.1, something like:<br />
<br />
A signed bit field of 1 bit length is treated as ...<br />
<br />
There is a danger of ...<br />
<br />
They are problematic when ...<br />
<br />
It is better not to use signed bit fields of 1 bit length use ...<br />
<br />
Jonathan]]></description>
			<content:encoded><![CDATA[Is it possible to improve Rule 6.5 "A signed bit field of 1 bit length is not useful". Unlike the other rules, this doesn't actually advise/recommend any behaviour or give any insight as to what compilers may or may not do when presented with this.<br />
<br />
How about - following the same outline structure of the following rule 7.1, something like:<br />
<br />
A signed bit field of 1 bit length is treated as ...<br />
<br />
There is a danger of ...<br />
<br />
They are problematic when ...<br />
<br />
It is better not to use signed bit fields of 1 bit length use ...<br />
<br />
Jonathan]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Does 5.6 or 5.7 apply to block scope identifiers?]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=518</link>
			<pubDate>Thu, 15 May 2008 15:30:53 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=64">gs</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=518</guid>
			<description><![CDATA[The rule reads:<br />
<blockquote class="mycode_quote"><cite>Quote:</cite><span style="font-weight: bold;" class="mycode_b">No identifier name should be reused.</span><br />
<br />
Regardless of scope, no identifier should be re-used across any files in the system.  This rule incorporates the provisions of Rules 5.2, 5.3, 5.4, 5.5 and 5.6.</blockquote>
<br />
Does this advisory apply to block scope variables?  The accompanying text says the rule incorporates the provisions of the other rules, but does not say if the rule is limited to just those provisions.<br />
<br />
Rule 5.7 appears to constitute a stricter version of rule 5.6, which raises the question, "Does 5.6 apply to block scope variables?" as well.]]></description>
			<content:encoded><![CDATA[The rule reads:<br />
<blockquote class="mycode_quote"><cite>Quote:</cite><span style="font-weight: bold;" class="mycode_b">No identifier name should be reused.</span><br />
<br />
Regardless of scope, no identifier should be re-used across any files in the system.  This rule incorporates the provisions of Rules 5.2, 5.3, 5.4, 5.5 and 5.6.</blockquote>
<br />
Does this advisory apply to block scope variables?  The accompanying text says the rule incorporates the provisions of the other rules, but does not say if the rule is limited to just those provisions.<br />
<br />
Rule 5.7 appears to constitute a stricter version of rule 5.6, which raises the question, "Does 5.6 apply to block scope variables?" as well.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rule 5.6 / Rule 5.7]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=289</link>
			<pubDate>Thu, 20 Jul 2006 15:48:40 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=97">sparker</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=289</guid>
			<description><![CDATA[I'm confused by the difference between the two examples in these two rules.  In R5.6 we're shown that it is ok to reuse the structure member identifier \"next\" since \"member names are less likely to be confused\", and in R5.7 we're shown that members of two different structure types cannot have the same name (\"speed\").<br />
<br />
Is the intention that one deviates from R5.7 leaving R5.6 to catch the most important cases?  If so that isn't very clear from the text.<br />
<br />
(Overall I'd be surprised if anyone ever sticks to R5.7 since it means that every identifier in your program, even every local, has to differ from every other.  That means no \"i\", \"j\", \"p\", \"speed\", \"rpm\", ..., \"index\", etc.)]]></description>
			<content:encoded><![CDATA[I'm confused by the difference between the two examples in these two rules.  In R5.6 we're shown that it is ok to reuse the structure member identifier \"next\" since \"member names are less likely to be confused\", and in R5.7 we're shown that members of two different structure types cannot have the same name (\"speed\").<br />
<br />
Is the intention that one deviates from R5.7 leaving R5.6 to catch the most important cases?  If so that isn't very clear from the text.<br />
<br />
(Overall I'd be surprised if anyone ever sticks to R5.7 since it means that every identifier in your program, even every local, has to differ from every other.  That means no \"i\", \"j\", \"p\", \"speed\", \"rpm\", ..., \"index\", etc.)]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rule 5.1]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=239</link>
			<pubDate>Wed, 05 Apr 2006 22:37:19 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=220">quangp</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=239</guid>
			<description><![CDATA[Need clarification on rule 5.1 (equivalenet to rule 11 in MISRA C1):<br />
<br />
Does this rule disallow to use identifier that has more than 31 characters? Even though the first 31 characters are guaranteed to be distinct.<br />
<br />
Thanks,<br />
<br />
quangp]]></description>
			<content:encoded><![CDATA[Need clarification on rule 5.1 (equivalenet to rule 11 in MISRA C1):<br />
<br />
Does this rule disallow to use identifier that has more than 31 characters? Even though the first 31 characters are guaranteed to be distinct.<br />
<br />
Thanks,<br />
<br />
quangp]]></content:encoded>
		</item>
	</channel>
</rss>