<?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.6 Types]]></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:25 +0000</pubDate>
		<generator>MyBB</generator>
		<item>
			<title><![CDATA[10.1 violated]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1194</link>
			<pubDate>Wed, 08 Jul 2015 05:34:34 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=3940">minnu</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1194</guid>
			<description><![CDATA[#define NUM <span style="color: #FF40BF;" class="mycode_color">9u</span><br />
#define NUM2<span style="color: #FF40FF;" class="mycode_color"> 8</span><br />
<br />
<br />
/* gus32cmd is keyboard entry .numbers from 1 to 10*/<br />
<br />
scanf("%d", &amp;gus32cmd );  <br />
<br />
Switch(gus32cmd)<br />
{<br />
<span style="color: #FF0000;" class="mycode_color">case:NUM</span><br />
....<br />
....<br />
break;<br />
<br />
<br />
<span style="color: #FF4000;" class="mycode_color">case NUM2</span><br />
..<br />
..<br />
break;<br />
<br />
}<br />
<br />
At lines case:NUM and case NUM2 I got following misra c error<br />
<br />
"Rule 10.1 violated "implicit conversion of complex integer expression to a small sized integer is not allowed"<br />
What correction I should do to avoid this error]]></description>
			<content:encoded><![CDATA[#define NUM <span style="color: #FF40BF;" class="mycode_color">9u</span><br />
#define NUM2<span style="color: #FF40FF;" class="mycode_color"> 8</span><br />
<br />
<br />
/* gus32cmd is keyboard entry .numbers from 1 to 10*/<br />
<br />
scanf("%d", &amp;gus32cmd );  <br />
<br />
Switch(gus32cmd)<br />
{<br />
<span style="color: #FF0000;" class="mycode_color">case:NUM</span><br />
....<br />
....<br />
break;<br />
<br />
<br />
<span style="color: #FF4000;" class="mycode_color">case NUM2</span><br />
..<br />
..<br />
break;<br />
<br />
}<br />
<br />
At lines case:NUM and case NUM2 I got following misra c error<br />
<br />
"Rule 10.1 violated "implicit conversion of complex integer expression to a small sized integer is not allowed"<br />
What correction I should do to avoid this error]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Clarification for Rule 6.1]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1172</link>
			<pubDate>Mon, 06 Apr 2015 09:02:40 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=3719">anuj1085</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1172</guid>
			<description><![CDATA[The rule says that the plain char should only be used to store character values.<br />
<br />
C standards says single character constant for eg. 'X' are int not char. So the following code:<br />
<br />
char x = 'A';<br />
<br />
is a violation of the rule as in this <span style="font-weight: bold;" class="mycode_b">char x is storing a constant whose type is "int"</span>. If this is not the violation then how to interpret this rule as the all single character constants are int according to "c" standards.]]></description>
			<content:encoded><![CDATA[The rule says that the plain char should only be used to store character values.<br />
<br />
C standards says single character constant for eg. 'X' are int not char. So the following code:<br />
<br />
char x = 'A';<br />
<br />
is a violation of the rule as in this <span style="font-weight: bold;" class="mycode_b">char x is storing a constant whose type is "int"</span>. If this is not the violation then how to interpret this rule as the all single character constants are int according to "c" standards.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[MISRA 6.1 with enum]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1055</link>
			<pubDate>Mon, 12 May 2014 08:51:18 +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=1055</guid>
			<description><![CDATA[Hi guys,<br />
<br />
 I am encountering some problems trying to make MISRA 6.1 compliant my source code,<br />
 expecially using enumeration.<br />
 <br />
From one side, in the header file I declare:<br />
typedef enum { FALLING_EDGE = 0x0, RISING_EDGE } t_EdgePolarity;<br />
 <br />
and from the other side, in the code I declare:<br />
emios_error_t EMIOS_PIN_Config(t_PIO_CHANNELS _channel,<br />
                              t_BusSelect _bsl,<br />
                              t_EdgeSelection _edgesel, <br />
                              t_EdgePolarity _edgepol, <br />
                              t_ActiveFilter _filter)<br />
{<br />
   ...   ...   ...   ...   ...   ...  <br />
   /* Do somthing */<br />
    switch (_edgepol) <br />
       case  FALLING_EDGE:<br />
          /* Do somthing */<br />
          break;<br />
       case  RISING_EDGE:<br />
          /* Do somthing */<br />
          break; <br />
      default:<br />
          /* Do somthing */<br />
         break;<br />
    ...   ...   ...   ...   ...<br />
}<br />
At compile time, green hills 5.1.6 compiler gives back this error message:<br />
MISRA 2004 Rule 6.1: <br />
          only assignment and equality operators may be used on plain char<br />
          operand<br />
      switch (_edgepol) <br />
               ^<br />
It is only an example, but I have same error with all the enumeration used in <br />
the code.<br />
<br />
Any suggestions? <br />
<br />
Thank you in advance,<br />
<br />
Andrea Mocci, embedded SW developer @ Akhela s.r.l.]]></description>
			<content:encoded><![CDATA[Hi guys,<br />
<br />
 I am encountering some problems trying to make MISRA 6.1 compliant my source code,<br />
 expecially using enumeration.<br />
 <br />
From one side, in the header file I declare:<br />
typedef enum { FALLING_EDGE = 0x0, RISING_EDGE } t_EdgePolarity;<br />
 <br />
and from the other side, in the code I declare:<br />
emios_error_t EMIOS_PIN_Config(t_PIO_CHANNELS _channel,<br />
                              t_BusSelect _bsl,<br />
                              t_EdgeSelection _edgesel, <br />
                              t_EdgePolarity _edgepol, <br />
                              t_ActiveFilter _filter)<br />
{<br />
   ...   ...   ...   ...   ...   ...  <br />
   /* Do somthing */<br />
    switch (_edgepol) <br />
       case  FALLING_EDGE:<br />
          /* Do somthing */<br />
          break;<br />
       case  RISING_EDGE:<br />
          /* Do somthing */<br />
          break; <br />
      default:<br />
          /* Do somthing */<br />
         break;<br />
    ...   ...   ...   ...   ...<br />
}<br />
At compile time, green hills 5.1.6 compiler gives back this error message:<br />
MISRA 2004 Rule 6.1: <br />
          only assignment and equality operators may be used on plain char<br />
          operand<br />
      switch (_edgepol) <br />
               ^<br />
It is only an example, but I have same error with all the enumeration used in <br />
the code.<br />
<br />
Any suggestions? <br />
<br />
Thank you in advance,<br />
<br />
Andrea Mocci, embedded SW developer @ Akhela s.r.l.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[6.2 and switch/case labels]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=1039</link>
			<pubDate>Tue, 11 Mar 2014 16:44:04 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=2560">dreser</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=1039</guid>
			<description><![CDATA[I'm not 100% sure on the interpretation of rule 6.2 when it comes to using "unsigned char" values as labels for switch case.<br />
<br />
Example:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>const uint8_t CONSTANT_ONE = 12U;<br />
const uint8_t CONSTANT_TWO = 34U;<br />
<br />
uint8_t value = foo();<br />
<br />
switch (value)<br />
{<br />
case CONSTANT_ONE:<br />
&nbsp;&nbsp;[...]<br />
&nbsp;&nbsp; break;<br />
case CONSTANT_TWO:<br />
&nbsp;&nbsp;[...]<br />
&nbsp;&nbsp; break;<br />
default:<br />
&nbsp;&nbsp;[...]<br />
&nbsp;&nbsp; break;<br />
}</code></div></div><br />
For each of the "case " lines PC-lint (from V9.00j on) complains about a "Disallowed use of non-numeric value in a case label".<br />
I would have considered defining and using the contants as "storage and use of numeric values" as described in 6.2.<br />
I also can not find a similar limitation in MISRA-C 2012. Though I might not have looked deeply enough as I only have it in printed form.<br />
<br />
Thanks for any feedback you might have on this.]]></description>
			<content:encoded><![CDATA[I'm not 100% sure on the interpretation of rule 6.2 when it comes to using "unsigned char" values as labels for switch case.<br />
<br />
Example:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>const uint8_t CONSTANT_ONE = 12U;<br />
const uint8_t CONSTANT_TWO = 34U;<br />
<br />
uint8_t value = foo();<br />
<br />
switch (value)<br />
{<br />
case CONSTANT_ONE:<br />
&nbsp;&nbsp;[...]<br />
&nbsp;&nbsp; break;<br />
case CONSTANT_TWO:<br />
&nbsp;&nbsp;[...]<br />
&nbsp;&nbsp; break;<br />
default:<br />
&nbsp;&nbsp;[...]<br />
&nbsp;&nbsp; break;<br />
}</code></div></div><br />
For each of the "case " lines PC-lint (from V9.00j on) complains about a "Disallowed use of non-numeric value in a case label".<br />
I would have considered defining and using the contants as "storage and use of numeric values" as described in 6.2.<br />
I also can not find a similar limitation in MISRA-C 2012. Though I might not have looked deeply enough as I only have it in printed form.<br />
<br />
Thanks for any feedback you might have on this.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Boolean typedef and rules 6.4 and 10.1]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=862</link>
			<pubDate>Thu, 10 Nov 2011 15:09:06 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=1823">rhbarnes</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=862</guid>
			<description><![CDATA[Hi, I need some advice regarding typedef and boolean types; we use the following typedefs in a common 'types' header file (I have only included the relevant ones here):<br />
<br />
typedef unsigned int uint16_t;<br />
typedef unsigned int bool_t;<br />
#define FALSE ((bool_t)0U)<br />
#define TRUE  ((bool_t)1U)<br />
<br />
If we create a structure containing a bit-field, for example..<br />
<br />
typedef struct<br />
{ // Structure used to pass software/hardware info to the system<br />
  i8pc_string_t i8pc_software_version;	// Software version number<br />
  i8pc_string_t i8pc_serial_number;	// Serial number<br />
  bool_t           bl_hardware_supported:1;	// Hardware revision is supported<br />
} st_software_info_t;<br />
<br />
and then modify the boolean member as such...<br />
<br />
sts_sw_info.bl_hardware_supported = FALSE; <br />
<br />
then this is ok, however when we test the value as such...<br />
<br />
if (sts_sw_info.bl_hardware_supported == FALSE)<br />
{<br />
  // Do something...<br />
}<br />
<br />
then we violate rule #10.1. Is this due to the underlying type expected by the if statement?<br />
<br />
In addition, if any bit-field is defined using a typdef'd type (e.g. uint16_t u4_my_bits:4<img src="https://forum.misra.org.uk/images/smilies/wink.png" alt="Wink" title="Wink" class="smilie smilie_2" />, then we violate rule 6.4; why is this since uint16_t has been typedef'd as unsigned int?<br />
<br />
Any help appreciated,<br />
<br />
Regards<br />
Richard]]></description>
			<content:encoded><![CDATA[Hi, I need some advice regarding typedef and boolean types; we use the following typedefs in a common 'types' header file (I have only included the relevant ones here):<br />
<br />
typedef unsigned int uint16_t;<br />
typedef unsigned int bool_t;<br />
#define FALSE ((bool_t)0U)<br />
#define TRUE  ((bool_t)1U)<br />
<br />
If we create a structure containing a bit-field, for example..<br />
<br />
typedef struct<br />
{ // Structure used to pass software/hardware info to the system<br />
  i8pc_string_t i8pc_software_version;	// Software version number<br />
  i8pc_string_t i8pc_serial_number;	// Serial number<br />
  bool_t           bl_hardware_supported:1;	// Hardware revision is supported<br />
} st_software_info_t;<br />
<br />
and then modify the boolean member as such...<br />
<br />
sts_sw_info.bl_hardware_supported = FALSE; <br />
<br />
then this is ok, however when we test the value as such...<br />
<br />
if (sts_sw_info.bl_hardware_supported == FALSE)<br />
{<br />
  // Do something...<br />
}<br />
<br />
then we violate rule #10.1. Is this due to the underlying type expected by the if statement?<br />
<br />
In addition, if any bit-field is defined using a typdef'd type (e.g. uint16_t u4_my_bits:4<img src="https://forum.misra.org.uk/images/smilies/wink.png" alt="Wink" title="Wink" class="smilie smilie_2" />, then we violate rule 6.4; why is this since uint16_t has been typedef'd as unsigned int?<br />
<br />
Any help appreciated,<br />
<br />
Regards<br />
Richard]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[6.2 With Respect to Arrays and Pointers?]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=762</link>
			<pubDate>Thu, 29 Jul 2010 15:23:34 +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=762</guid>
			<description><![CDATA[Is the following code permitted or prohibited by rule 6.2?<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>signed char a[10] = {"123456789"};<br />
signed char *b = "123456789";</code></div></div>]]></description>
			<content:encoded><![CDATA[Is the following code permitted or prohibited by rule 6.2?<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>signed char a[10] = {"123456789"};<br />
signed char *b = "123456789";</code></div></div>]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[6.4 and 6.5 with respect to unnamed bit fields?]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=731</link>
			<pubDate>Tue, 27 Apr 2010 16:24:08 +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=731</guid>
			<description><![CDATA[Do rules #6.4 and 6.4 apply to unnamed bit fields?  I would think, since the such fields are unnamed, one would not easily access them.]]></description>
			<content:encoded><![CDATA[Do rules #6.4 and 6.4 apply to unnamed bit fields?  I would think, since the such fields are unnamed, one would not easily access them.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Do enumerators count as "numeric values"?]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=724</link>
			<pubDate>Thu, 25 Mar 2010 13:04:06 +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=724</guid>
			<description><![CDATA[The commentary in the MISRA guidelines leaves the answer to this question unclear in my opinion due to the wording<blockquote class="mycode_quote"><cite>Quote:</cite>Numeric values/data are numbers such as 0, 5, 23, \x10, -3.</blockquote>
]]></description>
			<content:encoded><![CDATA[The commentary in the MISRA guidelines leaves the answer to this question unclear in my opinion due to the wording<blockquote class="mycode_quote"><cite>Quote:</cite>Numeric values/data are numbers such as 0, 5, 23, \x10, -3.</blockquote>
]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Mixing plain char and non-plain char within ?:]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=723</link>
			<pubDate>Wed, 24 Mar 2010 14:03:26 +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=723</guid>
			<description><![CDATA[The commentary for rules #6.1 and #6.2 state, <blockquote class="mycode_quote"><cite>Quote:</cite>[T]he second and third operands of the ternary conditional operator may both be of plain char type.</blockquote>
  Do these rules permit one of these two operands to have plain char type and the other to have signed char or unsigned char type?<br />
<br />
For that matter, what about the mixing of such operands with operators considered acceptable for use with objects of plain char type?  For example, do the rules permit the following:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>void function( char a, signed char b )<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;if( a == b )<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ /*&nbsp;&nbsp;do something&nbsp;&nbsp;*/ }<br />
&nbsp;&nbsp;&nbsp;&nbsp;}</code></div></div>?]]></description>
			<content:encoded><![CDATA[The commentary for rules #6.1 and #6.2 state, <blockquote class="mycode_quote"><cite>Quote:</cite>[T]he second and third operands of the ternary conditional operator may both be of plain char type.</blockquote>
  Do these rules permit one of these two operands to have plain char type and the other to have signed char or unsigned char type?<br />
<br />
For that matter, what about the mixing of such operands with operators considered acceptable for use with objects of plain char type?  For example, do the rules permit the following:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>void function( char a, signed char b )<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;if( a == b )<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ /*&nbsp;&nbsp;do something&nbsp;&nbsp;*/ }<br />
&nbsp;&nbsp;&nbsp;&nbsp;}</code></div></div>?]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Plain chars within structs?]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=720</link>
			<pubDate>Thu, 18 Mar 2010 15:53:57 +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=720</guid>
			<description><![CDATA[The commentary for rule 6.1 and 6.2 states<br />
<blockquote class="mycode_quote"><cite>Quote:</cite>The permissible operators on plain char types are the simple assignment operator (=), equality operators (==, !=) and explicit casts to integral types. Additionally, the second and third operands of the ternary conditional operator may both be of plain char type.</blockquote>
What about the '.' operator?  Or the '-&gt;' operator?  Could not an object of structure type contain a plain char member, making that member the second operand of the operator?<br />
<br />
What about bit addressing or sizeof?]]></description>
			<content:encoded><![CDATA[The commentary for rule 6.1 and 6.2 states<br />
<blockquote class="mycode_quote"><cite>Quote:</cite>The permissible operators on plain char types are the simple assignment operator (=), equality operators (==, !=) and explicit casts to integral types. Additionally, the second and third operands of the ternary conditional operator may both be of plain char type.</blockquote>
What about the '.' operator?  Or the '-&gt;' operator?  Could not an object of structure type contain a plain char member, making that member the second operand of the operator?<br />
<br />
What about bit addressing or sizeof?]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[6.1, 6.2 and casts?]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=719</link>
			<pubDate>Thu, 18 Mar 2010 14:31:11 +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=719</guid>
			<description><![CDATA[Does rule 6.1 permit a numeric value to be cast to plain char type and then assigned to an object of plain char?<br />
Does rule 6.2 permit a character value to be cast to signed/unsigned char type and then assigned to an object of signed/unsigned char?]]></description>
			<content:encoded><![CDATA[Does rule 6.1 permit a numeric value to be cast to plain char type and then assigned to an object of plain char?<br />
Does rule 6.2 permit a character value to be cast to signed/unsigned char type and then assigned to an object of signed/unsigned char?]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Bitfields vs masks for SFRs]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=624</link>
			<pubDate>Wed, 11 Feb 2009 16:51:28 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=777">TheDoctor</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=624</guid>
			<description><![CDATA[Is there a MISRA preferred route for accessing individual bit(s) in an SFR in an embedded micro?  In MISRA C1 Rule 110 stated that "unions shall not be used to access the sub-parts of larger data types" and in the explanatory text said that the preferred method was the use of unsigned integer types and masks. However in C2 the rule has changed to "no unions" and this particular recommendation doesn't seem to have made it into the text anywhere.<br />
<br />
Notwithstanding rule 18.4, on a micro I am working with at present the compiler writer provides access in the header file to each SFR through a union which overlays both a bitfield structure for the SFR and an unsigned object covering the whole width of the SFR. So if I want to extract (say) a 12-bit A/D value from an SFR location that contains the result as well as some other info e.g. status bits I can access this either as ADCchan.B.RESULT (where RESULT is a bitfield 12 bits wide) or ADCchan.U &amp; 0x00000fffU.]]></description>
			<content:encoded><![CDATA[Is there a MISRA preferred route for accessing individual bit(s) in an SFR in an embedded micro?  In MISRA C1 Rule 110 stated that "unions shall not be used to access the sub-parts of larger data types" and in the explanatory text said that the preferred method was the use of unsigned integer types and masks. However in C2 the rule has changed to "no unions" and this particular recommendation doesn't seem to have made it into the text anywhere.<br />
<br />
Notwithstanding rule 18.4, on a micro I am working with at present the compiler writer provides access in the header file to each SFR through a union which overlays both a bitfield structure for the SFR and an unsigned object covering the whole width of the SFR. So if I want to extract (say) a 12-bit A/D value from an SFR location that contains the result as well as some other info e.g. status bits I can access this either as ADCchan.B.RESULT (where RESULT is a bitfield 12 bits wide) or ADCchan.U &amp; 0x00000fffU.]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[int main() and rule 6.3]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=539</link>
			<pubDate>Mon, 23 Jun 2008 13:23:02 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=436">Lundin</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=539</guid>
			<description><![CDATA[I was wondering whether rule 6.3 applies to int main() or if this is should be a special exception? Ie should we write sint16_t main() or not?<br />
Because if we state the width and signedness of main() we will suddenly make the app implementation-dependant and non-portable.<br />
<br />
Also, ISO C strictly states that the return type shall be "int" on a hosted environment. One could interpret that as "it must be the primitive<br />
data type int and no custom typedef".]]></description>
			<content:encoded><![CDATA[I was wondering whether rule 6.3 applies to int main() or if this is should be a special exception? Ie should we write sint16_t main() or not?<br />
Because if we state the width and signedness of main() we will suddenly make the app implementation-dependant and non-portable.<br />
<br />
Also, ISO C strictly states that the return type shall be "int" on a hosted environment. One could interpret that as "it must be the primitive<br />
data type int and no custom typedef".]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rule 6.5 and unnamed 0-length bit field]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=439</link>
			<pubDate>Tue, 08 Jan 2008 14:44:47 +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=439</guid>
			<description><![CDATA[What about following case:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>struct s {<br />
&nbsp;&nbsp;&nbsp;&nbsp;signed int : 0;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* Is Rule 6.5 violated? */<br />
&nbsp;&nbsp;};</code></div></div><br />
Rule 6.5 explicitly says that \"Bit fields of type signed int shall be at least 2 bits long.\" (or \"Bit fields of signed type shall be at least 2 bits long.\" in TC1). <br />
<br />
This bit field is clearly smaller than 2 bits, but it serves other purpose than \"normal\" positive-size bit fields.<br />
<br />
Should the code be changed to use \"unsigned int\" type (the rule would not apply), or is the 0-size bit field an exception to this rule?]]></description>
			<content:encoded><![CDATA[What about following case:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>struct s {<br />
&nbsp;&nbsp;&nbsp;&nbsp;signed int : 0;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* Is Rule 6.5 violated? */<br />
&nbsp;&nbsp;};</code></div></div><br />
Rule 6.5 explicitly says that \"Bit fields of type signed int shall be at least 2 bits long.\" (or \"Bit fields of signed type shall be at least 2 bits long.\" in TC1). <br />
<br />
This bit field is clearly smaller than 2 bits, but it serves other purpose than \"normal\" positive-size bit fields.<br />
<br />
Should the code be changed to use \"unsigned int\" type (the rule would not apply), or is the 0-size bit field an exception to this rule?]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Boolean Types]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=338</link>
			<pubDate>Mon, 05 Feb 2007 19:08:23 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=271">djtachyon</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=338</guid>
			<description><![CDATA[Just wondering what is the best way to define a boolean type for MISRA and most importantly what to define TRUE and FALSE as.<br />
<br />
Some thoughts:<br />
<br />
typedef unsigned char boolean_t<br />
#define TRUE (0==0)<br />
#define FALSE (!0)<br />
<br />
Thanks.]]></description>
			<content:encoded><![CDATA[Just wondering what is the best way to define a boolean type for MISRA and most importantly what to define TRUE and FALSE as.<br />
<br />
Some thoughts:<br />
<br />
typedef unsigned char boolean_t<br />
#define TRUE (0==0)<br />
#define FALSE (!0)<br />
<br />
Thanks.]]></content:encoded>
		</item>
	</channel>
</rss>