<?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.8 Declarations and Definitions]]></title>
		<link>https://forum.misra.org.uk/</link>
		<description><![CDATA[MISRA Discussion Forums - https://forum.misra.org.uk]]></description>
		<pubDate>Thu, 05 Nov 2026 19:06:27 +0000</pubDate>
		<generator>MyBB</generator>
		<item>
			<title><![CDATA[Rule 8.3 Function definition]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1401</link>
			<pubDate>Wed, 21 Feb 2018 10:12:20 +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=1401</guid>
			<description><![CDATA[I want to just clarify that following is a MISRA violation before using it in my code. I am calling one function from a file as under:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>(void)Dem_SetEventStatus((Dem_EventIdType)(dtcFlt_t.dtc[dtcIndex]), DEM_EVENT_STATUS_FAILED);</code></div></div><br />
Here Dem_SetEventStatus is defined in one header as under:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>extern FUNC(Std_ReturnType, RTE_CODE) Dem_SetEventStatus (Dem_ASR42_EventIdType EventId, Dem_ASR42_EventStatusType EventStatus);</code></div></div><br />
Here Dem_EventIdType is a typedef of unit8 and Dem_ASR42_EventIdType is unsigned short.<br />
<br />
So , there were the violation of MISRA 8.3 right??]]></description>
			<content:encoded><![CDATA[I want to just clarify that following is a MISRA violation before using it in my code. I am calling one function from a file as under:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>(void)Dem_SetEventStatus((Dem_EventIdType)(dtcFlt_t.dtc[dtcIndex]), DEM_EVENT_STATUS_FAILED);</code></div></div><br />
Here Dem_SetEventStatus is defined in one header as under:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>extern FUNC(Std_ReturnType, RTE_CODE) Dem_SetEventStatus (Dem_ASR42_EventIdType EventId, Dem_ASR42_EventStatusType EventStatus);</code></div></div><br />
Here Dem_EventIdType is a typedef of unit8 and Dem_ASR42_EventIdType is unsigned short.<br />
<br />
So , there were the violation of MISRA 8.3 right??]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rule 8.3: Symbol  redeclared]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1399</link>
			<pubDate>Fri, 16 Feb 2018 12:34:55 +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=1399</guid>
			<description><![CDATA[Hello,<br />
<br />
I am facing an issue relating to rule 8.3. I am fixing MISRA violations in the project. The following code line is where i have issue:<br />
<br />
in one of the files in the project i have the following code line:<br />
<br />
dies-&gt;DrvPosn_D_SvRc_Rq = get_DrvPosn_D_SvRc_Rq();<br />
<br />
get_DrvPosn_D_SvRc_Rq() is defined in other file as below:<br />
<br />
tm_uint8 get_DrvPosn_D_SvRc_Rq(void)<br />
{<br />
    return cio_DrvPosn_D_SvRc_Rq;<br />
}<br />
<br />
When i am performing the MISRA check , i get a error at 'dies-&gt;DrvPosn_D_SvRc_Rq = get_DrvPosn_D_SvRc_Rq();' line saying that Symbol 'get_DrvPosn_D_SvRc_Rq(void)' redeclared  .<br />
<br />
All the variables have same datatype tm_uint8;<br />
<br />
Can you point out where the issue lies?<br />
<br />
Thank you!<br />
<br />
Ankit]]></description>
			<content:encoded><![CDATA[Hello,<br />
<br />
I am facing an issue relating to rule 8.3. I am fixing MISRA violations in the project. The following code line is where i have issue:<br />
<br />
in one of the files in the project i have the following code line:<br />
<br />
dies-&gt;DrvPosn_D_SvRc_Rq = get_DrvPosn_D_SvRc_Rq();<br />
<br />
get_DrvPosn_D_SvRc_Rq() is defined in other file as below:<br />
<br />
tm_uint8 get_DrvPosn_D_SvRc_Rq(void)<br />
{<br />
    return cio_DrvPosn_D_SvRc_Rq;<br />
}<br />
<br />
When i am performing the MISRA check , i get a error at 'dies-&gt;DrvPosn_D_SvRc_Rq = get_DrvPosn_D_SvRc_Rq();' line saying that Symbol 'get_DrvPosn_D_SvRc_Rq(void)' redeclared  .<br />
<br />
All the variables have same datatype tm_uint8;<br />
<br />
Can you point out where the issue lies?<br />
<br />
Thank you!<br />
<br />
Ankit]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rule 8.5 - #define with function code in header files]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1199</link>
			<pubDate>Tue, 18 Aug 2015 14:47:16 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=3639">reito</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1199</guid>
			<description><![CDATA[Hello,<br />
I would like to confirm the following interpretation of the rule 8.5. The rule says that "Header files should be used to declare objects, functions, typedefs, and macros. Header files shall not contain or produce definitions of objects or functions (or fragment of functions or objects) that occupy storage."<br />
<br />
I have seen a couple of alerts in code raised when the header file contains a macro that generates the "body of one function".  My understanding is that this is the case where the "macro produces definitions of objects or functions", and that this is a violation to be corrected.<br />
<br />
In a similar way, if the header file contains a #typedef for an struct, should it be considered a violation to this rule?<br />
<br />
Thanks in advance.]]></description>
			<content:encoded><![CDATA[Hello,<br />
I would like to confirm the following interpretation of the rule 8.5. The rule says that "Header files should be used to declare objects, functions, typedefs, and macros. Header files shall not contain or produce definitions of objects or functions (or fragment of functions or objects) that occupy storage."<br />
<br />
I have seen a couple of alerts in code raised when the header file contains a macro that generates the "body of one function".  My understanding is that this is the case where the "macro produces definitions of objects or functions", and that this is a violation to be corrected.<br />
<br />
In a similar way, if the header file contains a #typedef for an struct, should it be considered a violation to this rule?<br />
<br />
Thanks in advance.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[MISRA 8.5 with inline function]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1056</link>
			<pubDate>Thu, 15 May 2014 13:51:25 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=3070">ziomocci</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1056</guid>
			<description><![CDATA[Hi guys,<br />
 <br />
 I have an header file with inline function, like:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>inline void DIGIO_InOut(uint8_T type, uint16_T pid)<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;/* Do something */<br />
}</code></div></div>and, without MISRA 8.5 activated, I am able to use/export methods without problems.<br />
<br />
Well, activating the rules, of course I can not keep body of inline function inside header file (just for info, I am using ghs compiler).<br />
Is it possible to put declaration of inline function in  and declaration in , like:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>inline void DIGIO_InOut(uint8_T type, uint16_T pid);<br />
<br />
<br />
inline void DIGIO_InOut(uint8_T type, uint16_T pid)<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;/* Do something */<br />
}</code></div></div>?<br />
<br />
Thank you in advance,<br />
<br />
Best regards,<br />
<br />
Andrea Mocci, Embedded SW developer at Akhela s.r.l.]]></description>
			<content:encoded><![CDATA[Hi guys,<br />
 <br />
 I have an header file with inline function, like:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>inline void DIGIO_InOut(uint8_T type, uint16_T pid)<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;/* Do something */<br />
}</code></div></div>and, without MISRA 8.5 activated, I am able to use/export methods without problems.<br />
<br />
Well, activating the rules, of course I can not keep body of inline function inside header file (just for info, I am using ghs compiler).<br />
Is it possible to put declaration of inline function in  and declaration in , like:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>inline void DIGIO_InOut(uint8_T type, uint16_T pid);<br />
<br />
<br />
inline void DIGIO_InOut(uint8_T type, uint16_T pid)<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;/* Do something */<br />
}</code></div></div>?<br />
<br />
Thank you in advance,<br />
<br />
Best regards,<br />
<br />
Andrea Mocci, Embedded SW developer at Akhela s.r.l.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[MISRA 8.1]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=957</link>
			<pubDate>Wed, 10 Apr 2013 09:17:25 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=2595">spd123</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=957</guid>
			<description><![CDATA[Hi,<br />
<br />
[ MISRA 8.1 ] Functions shall have prototype and prototype shall be visible at both the definition and call<br />
<br />
I am using cystal revs for C MISRA C 2004 compliance.<br />
Its showing violation in following code. pl. suggest solution for this. <br />
<br />
controller specific header file<br />
-----------------------------------------<br />
SFR( P0, 0x80U ); /* Port 0 Latch */<br />
<br />
Main.c<br />
----------<br />
void main( void )<br />
Global_Frame[ 0 ] = ( U8 )( Mid_No &amp; 0x1fU ); /* bit of mid */]]></description>
			<content:encoded><![CDATA[Hi,<br />
<br />
[ MISRA 8.1 ] Functions shall have prototype and prototype shall be visible at both the definition and call<br />
<br />
I am using cystal revs for C MISRA C 2004 compliance.<br />
Its showing violation in following code. pl. suggest solution for this. <br />
<br />
controller specific header file<br />
-----------------------------------------<br />
SFR( P0, 0x80U ); /* Port 0 Latch */<br />
<br />
Main.c<br />
----------<br />
void main( void )<br />
Global_Frame[ 0 ] = ( U8 )( Mid_No &amp; 0x1fU ); /* bit of mid */]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[8.7 and design for testatbility]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=937</link>
			<pubDate>Thu, 24 Jan 2013 15:08:56 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=918">ggentile</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=937</guid>
			<description><![CDATA[It seems that the 8.7 rule contradict design for testability.<br />
Infact when you have a static variabile defined at block level, right now you have no way to perform any white box testing withot changing/adding code to copy the value to a global variable.<br />
<br />
Let me know<br />
<br />
Giacomo]]></description>
			<content:encoded><![CDATA[It seems that the 8.7 rule contradict design for testability.<br />
Infact when you have a static variabile defined at block level, right now you have no way to perform any white box testing withot changing/adding code to copy the value to a global variable.<br />
<br />
Let me know<br />
<br />
Giacomo]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[8.9 and 3rd party library code]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=889</link>
			<pubDate>Mon, 19 Mar 2012 15:32:35 +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=889</guid>
			<description><![CDATA[Hi,<br />
    Does rule #8.9 apply to objects/functions declared in 3rd party library code?<br />
<br />
Thanks]]></description>
			<content:encoded><![CDATA[Hi,<br />
    Does rule #8.9 apply to objects/functions declared in 3rd party library code?<br />
<br />
Thanks]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Does this code violate rule #8.7?]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=882</link>
			<pubDate>Wed, 15 Feb 2012 19:30:50 +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=882</guid>
			<description><![CDATA[Given this example<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>file1.c:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;static int i;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int j[1] = { i };<br />
file2.c:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;extern int j[1];<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;void f()<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int k = j[0];<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</code></div></div>Does this code violate rule #8.7, "Objects shall be defined at block scope if they are only accessed from within a single function"?]]></description>
			<content:encoded><![CDATA[Given this example<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>file1.c:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;static int i;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int j[1] = { i };<br />
file2.c:<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;extern int j[1];<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;void f()<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;int k = j[0];<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</code></div></div>Does this code violate rule #8.7, "Objects shall be defined at block scope if they are only accessed from within a single function"?]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rule #8.7 for "special function registers" and others?]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=831</link>
			<pubDate>Wed, 15 Jun 2011 19:39:07 +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=831</guid>
			<description><![CDATA[Does this rule apply to objects which cannot be declared at block scope, like special function register variables?]]></description>
			<content:encoded><![CDATA[Does this rule apply to objects which cannot be declared at block scope, like special function register variables?]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Meaning of rule 8.4 for function prototypes]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=820</link>
			<pubDate>Wed, 30 Mar 2011 08:02:34 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=159">dcrocker</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=820</guid>
			<description><![CDATA[Consider the following:<br />
<br />
File1.h:<br />
typedef short int int16_t;<br />
<br />
File2.h:<br />
short int foo(short int a);<br />
<br />
File3.h:<br />
int16_t foo(int16_t a);<br />
<br />
Does this break any MISRA rules? I ask because rule 8.3 states that for a function, the types in the prototype must match the types in the definition *exactly*. However, rule 8.4 states that when an object *or function* is declared more than once, the types in the declarations must be compatible, which is a weaker requirement. Why were the words "or function" included in rule 8.4?<br />
<br />
My intepretation is that if my source code includes a definition of function foo, then I must be violating rules 8.3 (because at most one of the prototypes can have types that exactly match the types in the definition); but it my code doesn't include a definition for foo (e.g. because it is in a compiler-supplied library), I am free to provide two or more prototypes for it with non-identical but compatible types.]]></description>
			<content:encoded><![CDATA[Consider the following:<br />
<br />
File1.h:<br />
typedef short int int16_t;<br />
<br />
File2.h:<br />
short int foo(short int a);<br />
<br />
File3.h:<br />
int16_t foo(int16_t a);<br />
<br />
Does this break any MISRA rules? I ask because rule 8.3 states that for a function, the types in the prototype must match the types in the definition *exactly*. However, rule 8.4 states that when an object *or function* is declared more than once, the types in the declarations must be compatible, which is a weaker requirement. Why were the words "or function" included in rule 8.4?<br />
<br />
My intepretation is that if my source code includes a definition of function foo, then I must be violating rules 8.3 (because at most one of the prototypes can have types that exactly match the types in the definition); but it my code doesn't include a definition for foo (e.g. because it is in a compiler-supplied library), I am free to provide two or more prototypes for it with non-identical but compatible types.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rule 8.10 Register Mapping]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=728</link>
			<pubDate>Wed, 31 Mar 2010 07:52:05 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=955">mshearer123</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=728</guid>
			<description><![CDATA[Hi,<br />
I am using IBM logiscope to bring a pic24 project to MISRA compliance.<br />
<br />
Due to the use of unions in the standard PIC header file (which maps all the registers to the locations in the linker)  I have created my own local register mappings whenever needed.<br />
<br />
i.e. for PORT configuration source, the header contains <br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>extern volatile unsigned int&nbsp;&nbsp;TRISA;<br />
typedef struct <br />
{<br />
&nbsp;&nbsp;unsigned TRISA0:1;<br />
&nbsp;&nbsp;unsigned TRISA1:1;<br />
&nbsp;&nbsp;unsigned TRISA2:1;<br />
&nbsp;&nbsp;unsigned TRISA3:1;<br />
&nbsp;&nbsp;unsigned TRISA4:1;<br />
&nbsp;&nbsp;unsigned :2;<br />
&nbsp;&nbsp;unsigned TRISA7:1;<br />
&nbsp;&nbsp;unsigned TRISA8:1;<br />
&nbsp;&nbsp;unsigned TRISA9:1;<br />
&nbsp;&nbsp;unsigned TRISA10:1;<br />
} TRISABITS;<br />
extern volatile TRISABITS TRISAbits;<br />
<br />
extern volatile unsigned int TRISB;<br />
typedef struct<br />
 {<br />
&nbsp;&nbsp;unsigned TRISB0:1;<br />
&nbsp;&nbsp;unsigned TRISB1:1;<br />
&nbsp;&nbsp;unsigned TRISB2:1;<br />
&nbsp;&nbsp;unsigned TRISB3:1;<br />
&nbsp;&nbsp;unsigned TRISB4:1;<br />
&nbsp;&nbsp;unsigned TRISB5:1;<br />
&nbsp;&nbsp;unsigned TRISB6:1;<br />
&nbsp;&nbsp;unsigned TRISB7:1;<br />
&nbsp;&nbsp;unsigned TRISB8:1;<br />
&nbsp;&nbsp;unsigned TRISB9:1;<br />
&nbsp;&nbsp;unsigned TRISB10:1;<br />
&nbsp;&nbsp;unsigned TRISB11:1;<br />
&nbsp;&nbsp;unsigned TRISB12:1;<br />
&nbsp;&nbsp;unsigned TRISB13:1;<br />
&nbsp;&nbsp;unsigned TRISB14:1;<br />
&nbsp;&nbsp;unsigned TRISB15:1;<br />
} TRISBBITS;<br />
extern volatile TRISBBITS TRISBbits;<br />
<br />
extern volatile unsigned int&nbsp;&nbsp;TRISC;<br />
typedef struct<br />
{<br />
&nbsp;&nbsp;unsigned TRISC0:1;<br />
&nbsp;&nbsp;unsigned TRISC1:1;<br />
&nbsp;&nbsp;unsigned TRISC2:1;<br />
&nbsp;&nbsp;unsigned TRISC3:1;<br />
&nbsp;&nbsp;unsigned TRISC4:1;<br />
&nbsp;&nbsp;unsigned TRISC5:1;<br />
&nbsp;&nbsp;unsigned TRISC6:1;<br />
&nbsp;&nbsp;unsigned TRISC7:1;<br />
&nbsp;&nbsp;unsigned TRISC8:1;<br />
&nbsp;&nbsp;unsigned TRISC9:1;<br />
} TRISCBITS;<br />
extern volatile TRISCBITS TRISCbits;<br />
<br />
extern volatile unsigned int&nbsp;&nbsp;LATA;<br />
typedef struct<br />
{<br />
&nbsp;&nbsp;unsigned LATA0:1;<br />
&nbsp;&nbsp;unsigned LATA1:1;<br />
&nbsp;&nbsp;unsigned LATA2:1;<br />
&nbsp;&nbsp;unsigned LATA3:1;<br />
&nbsp;&nbsp;unsigned LATA4:1;<br />
&nbsp;&nbsp;unsigned :2;<br />
&nbsp;&nbsp;unsigned LATA7:1;<br />
&nbsp;&nbsp;unsigned LATA8:1;<br />
&nbsp;&nbsp;unsigned LATA9:1;<br />
&nbsp;&nbsp;unsigned LATA10:1;<br />
} LATABITS;<br />
extern volatile LATABITS LATAbits;</code></div></div><br />
The problem is, I don't have the linker file contained in my project, so therefore logiscope misses it and suggests all the <span style="font-weight: bold;" class="mycode_b">extern</span> variables should be <span style="font-weight: bold;" class="mycode_b">static</span>.<br />
How can get around this?<br />
<br />
Matthew Shearer]]></description>
			<content:encoded><![CDATA[Hi,<br />
I am using IBM logiscope to bring a pic24 project to MISRA compliance.<br />
<br />
Due to the use of unions in the standard PIC header file (which maps all the registers to the locations in the linker)  I have created my own local register mappings whenever needed.<br />
<br />
i.e. for PORT configuration source, the header contains <br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>extern volatile unsigned int&nbsp;&nbsp;TRISA;<br />
typedef struct <br />
{<br />
&nbsp;&nbsp;unsigned TRISA0:1;<br />
&nbsp;&nbsp;unsigned TRISA1:1;<br />
&nbsp;&nbsp;unsigned TRISA2:1;<br />
&nbsp;&nbsp;unsigned TRISA3:1;<br />
&nbsp;&nbsp;unsigned TRISA4:1;<br />
&nbsp;&nbsp;unsigned :2;<br />
&nbsp;&nbsp;unsigned TRISA7:1;<br />
&nbsp;&nbsp;unsigned TRISA8:1;<br />
&nbsp;&nbsp;unsigned TRISA9:1;<br />
&nbsp;&nbsp;unsigned TRISA10:1;<br />
} TRISABITS;<br />
extern volatile TRISABITS TRISAbits;<br />
<br />
extern volatile unsigned int TRISB;<br />
typedef struct<br />
 {<br />
&nbsp;&nbsp;unsigned TRISB0:1;<br />
&nbsp;&nbsp;unsigned TRISB1:1;<br />
&nbsp;&nbsp;unsigned TRISB2:1;<br />
&nbsp;&nbsp;unsigned TRISB3:1;<br />
&nbsp;&nbsp;unsigned TRISB4:1;<br />
&nbsp;&nbsp;unsigned TRISB5:1;<br />
&nbsp;&nbsp;unsigned TRISB6:1;<br />
&nbsp;&nbsp;unsigned TRISB7:1;<br />
&nbsp;&nbsp;unsigned TRISB8:1;<br />
&nbsp;&nbsp;unsigned TRISB9:1;<br />
&nbsp;&nbsp;unsigned TRISB10:1;<br />
&nbsp;&nbsp;unsigned TRISB11:1;<br />
&nbsp;&nbsp;unsigned TRISB12:1;<br />
&nbsp;&nbsp;unsigned TRISB13:1;<br />
&nbsp;&nbsp;unsigned TRISB14:1;<br />
&nbsp;&nbsp;unsigned TRISB15:1;<br />
} TRISBBITS;<br />
extern volatile TRISBBITS TRISBbits;<br />
<br />
extern volatile unsigned int&nbsp;&nbsp;TRISC;<br />
typedef struct<br />
{<br />
&nbsp;&nbsp;unsigned TRISC0:1;<br />
&nbsp;&nbsp;unsigned TRISC1:1;<br />
&nbsp;&nbsp;unsigned TRISC2:1;<br />
&nbsp;&nbsp;unsigned TRISC3:1;<br />
&nbsp;&nbsp;unsigned TRISC4:1;<br />
&nbsp;&nbsp;unsigned TRISC5:1;<br />
&nbsp;&nbsp;unsigned TRISC6:1;<br />
&nbsp;&nbsp;unsigned TRISC7:1;<br />
&nbsp;&nbsp;unsigned TRISC8:1;<br />
&nbsp;&nbsp;unsigned TRISC9:1;<br />
} TRISCBITS;<br />
extern volatile TRISCBITS TRISCbits;<br />
<br />
extern volatile unsigned int&nbsp;&nbsp;LATA;<br />
typedef struct<br />
{<br />
&nbsp;&nbsp;unsigned LATA0:1;<br />
&nbsp;&nbsp;unsigned LATA1:1;<br />
&nbsp;&nbsp;unsigned LATA2:1;<br />
&nbsp;&nbsp;unsigned LATA3:1;<br />
&nbsp;&nbsp;unsigned LATA4:1;<br />
&nbsp;&nbsp;unsigned :2;<br />
&nbsp;&nbsp;unsigned LATA7:1;<br />
&nbsp;&nbsp;unsigned LATA8:1;<br />
&nbsp;&nbsp;unsigned LATA9:1;<br />
&nbsp;&nbsp;unsigned LATA10:1;<br />
} LATABITS;<br />
extern volatile LATABITS LATAbits;</code></div></div><br />
The problem is, I don't have the linker file contained in my project, so therefore logiscope misses it and suggests all the <span style="font-weight: bold;" class="mycode_b">extern</span> variables should be <span style="font-weight: bold;" class="mycode_b">static</span>.<br />
How can get around this?<br />
<br />
Matthew Shearer]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[8.7 if applied to C++]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=716</link>
			<pubDate>Mon, 15 Mar 2010 18:25:09 +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=716</guid>
			<description><![CDATA[Suppose one wanted to ensure one's C++ code complied with the MISRA C guidelines.  Would a static data member of a struct or class be permitted to be accessed by only one function or should that static member be defined at block scope?  Suppose the struct/class type were a local one?  Would moving the definition of the static member out of the class and directly into block scope provide any benefit?]]></description>
			<content:encoded><![CDATA[Suppose one wanted to ensure one's C++ code complied with the MISRA C guidelines.  Would a static data member of a struct or class be permitted to be accessed by only one function or should that static member be defined at block scope?  Suppose the struct/class type were a local one?  Would moving the definition of the static member out of the class and directly into block scope provide any benefit?]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[8.7 wording?]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=709</link>
			<pubDate>Thu, 25 Feb 2010 19:47: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=709</guid>
			<description><![CDATA[Am I correct in presuming "Objects shall be defined at block scope if they are only accessed from within a single function," should read <span style="font-style: italic;" class="mycode_i">declared</span> instead of <span style="font-style: italic;" class="mycode_i">defined</span>?]]></description>
			<content:encoded><![CDATA[Am I correct in presuming "Objects shall be defined at block scope if they are only accessed from within a single function," should read <span style="font-style: italic;" class="mycode_i">declared</span> instead of <span style="font-style: italic;" class="mycode_i">defined</span>?]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rule 8.1 and static functions]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=657</link>
			<pubDate>Fri, 22 May 2009 12:47:13 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=833">Renishug</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=657</guid>
			<description><![CDATA[Rule 8.1 states, "Functions shall have prototype declarations and the prototype shall be visible at both the function definition and call."<br />
<br />
My question concerns a subset situation of this rule: why should functions marked static have prototype declarations visible at the function definition?<br />
<br />
Here is an example of the scenario, all in the same .c file:<br />
<br />
static int8_t my_function( void );<br />
<br />
...<br />
<br />
float64_t my_other_function( void )<br />
{<br />
   ...<br />
   my_int8_var = my_function();<br />
   ...<br />
}<br />
<br />
<br />
static int8_t my_function( void )<br />
{<br />
   ...<br />
}<br />
<br />
<br />
Elsewhere in the file there my be other calls of my_function too. This file conforms to rule 8.1. If I re-arrange the textual order of the file to make sure that the definition of my_function occurs before any calls of it, then the prototype effectively becomes redundant:<br />
<br />
static int8_t my_function( void );<br />
<br />
<br />
static int8_t my_function( void )<br />
{<br />
   ...<br />
}<br />
<br />
...<br />
<br />
float64_t my_other_function( void )<br />
{<br />
   ...<br />
   my_int8_var = my_function();<br />
   ...<br />
}<br />
<br />
<br />
<br />
Realistically, the prototype for my_function, usually placed towards the top of the .c file, is done by copy and paste from the function definition, with a semicolon added to the end of it. To me, as long as the textual order is right, the prototype just becomes something with no value to maintain, e.g. if you were to alter the function signature you would have to do so in two places rather than just one.<br />
<br />
I have tried to work out why MISRA would want the rule as it is, inclusive of static functions. (I'm ok with the rule otherwise.) I reckon that it might be for this reason: the prototype for static functions are there for the day when someone does some maintenance on the .c file and adds a call to a static function textually before the definition of the function. With a prototype there, the call would be checked for consistency; without a prototype there, if the maintainer forgets to alter the textual order of the function definitions, the function call is unchecked and so has a risk of being in error.<br />
<br />
Have I answered my own question?]]></description>
			<content:encoded><![CDATA[Rule 8.1 states, "Functions shall have prototype declarations and the prototype shall be visible at both the function definition and call."<br />
<br />
My question concerns a subset situation of this rule: why should functions marked static have prototype declarations visible at the function definition?<br />
<br />
Here is an example of the scenario, all in the same .c file:<br />
<br />
static int8_t my_function( void );<br />
<br />
...<br />
<br />
float64_t my_other_function( void )<br />
{<br />
   ...<br />
   my_int8_var = my_function();<br />
   ...<br />
}<br />
<br />
<br />
static int8_t my_function( void )<br />
{<br />
   ...<br />
}<br />
<br />
<br />
Elsewhere in the file there my be other calls of my_function too. This file conforms to rule 8.1. If I re-arrange the textual order of the file to make sure that the definition of my_function occurs before any calls of it, then the prototype effectively becomes redundant:<br />
<br />
static int8_t my_function( void );<br />
<br />
<br />
static int8_t my_function( void )<br />
{<br />
   ...<br />
}<br />
<br />
...<br />
<br />
float64_t my_other_function( void )<br />
{<br />
   ...<br />
   my_int8_var = my_function();<br />
   ...<br />
}<br />
<br />
<br />
<br />
Realistically, the prototype for my_function, usually placed towards the top of the .c file, is done by copy and paste from the function definition, with a semicolon added to the end of it. To me, as long as the textual order is right, the prototype just becomes something with no value to maintain, e.g. if you were to alter the function signature you would have to do so in two places rather than just one.<br />
<br />
I have tried to work out why MISRA would want the rule as it is, inclusive of static functions. (I'm ok with the rule otherwise.) I reckon that it might be for this reason: the prototype for static functions are there for the day when someone does some maintenance on the .c file and adds a call to a static function textually before the definition of the function. With a prototype there, the call would be checked for consistency; without a prototype there, if the maintainer forgets to alter the textual order of the function definitions, the function call is unchecked and so has a risk of being in error.<br />
<br />
Have I answered my own question?]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rule 8.10 and init functions]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=598</link>
			<pubDate>Fri, 28 Nov 2008 09:41:56 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=738">Christoph</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=598</guid>
			<description><![CDATA[Hi,<br />
<br />
usualy when a C module is designed (at our company), it consists of at least one external function. An example:<br />
<br />
module.h:<br />
extern void initModule()<br />
extern void setData(uint8_t data)<br />
extern uint8_t getData()<br />
<br />
now initModule() is called in main (once in the whole software), as it is an init function. From a design point of<br />
view module.* is the right place for initModule(), but Misra suggests to define it in main, since it is only called there.<br />
I think this is bad design and not always possible (e.g. because module variables are hidden and not accessible form main).<br />
<br />
So what is your recommendation in such a case? Is there a best practice for this pattern?<br />
<br />
Best Regards<br />
Christoph]]></description>
			<content:encoded><![CDATA[Hi,<br />
<br />
usualy when a C module is designed (at our company), it consists of at least one external function. An example:<br />
<br />
module.h:<br />
extern void initModule()<br />
extern void setData(uint8_t data)<br />
extern uint8_t getData()<br />
<br />
now initModule() is called in main (once in the whole software), as it is an init function. From a design point of<br />
view module.* is the right place for initModule(), but Misra suggests to define it in main, since it is only called there.<br />
I think this is bad design and not always possible (e.g. because module variables are hidden and not accessible form main).<br />
<br />
So what is your recommendation in such a case? Is there a best practice for this pattern?<br />
<br />
Best Regards<br />
Christoph]]></content:encoded>
		</item>
	</channel>
</rss>