<?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.7 Constants]]></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:13:14 +0000</pubDate>
		<generator>MyBB</generator>
		<item>
			<title><![CDATA[MISRA rule 7.1 Octal constants vs. Linux permissions]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=874</link>
			<pubDate>Wed, 25 Jan 2012 13:59:50 +0000</pubDate>
			<dc:creator><![CDATA[<a href="https://forum.misra.org.uk/member.php?action=profile&uid=274">tharris</a>]]></dc:creator>
			<guid isPermaLink="false">https://forum.misra.org.uk/showthread.php?tid=874</guid>
			<description><![CDATA[MISRA rule 7.1 says don't use octal constants, and gives good reasons.<br />
But code which sets and uses constants which represent Linux file permissions (see, for example, <a href="http://www.zzee.com/solutions/linux-permissions.shtml#numeric" target="_blank" rel="noopener" class="mycode_url">http://www.zzee.com/solutions/linux-perm...ml#numeric</a>), are necessarily octal and code is more readable in that case in octal -- the "native" format for such constants.<br />
<br />
Of course an octal number can be written, with the same digits, as hexadecimal, and that would meet the MISRA constraint. But IMHO would not meet the spirit of this rule, which is to avoid writing digits outside the base of the number by mistake. Writing a Linux file permissions constant as hex would mean that by mistake the developer could write a digit between 8 and F, and static analysis (compiler etc) would not catch it because it's legal hex. But illegal file permission digit.<br />
<br />
Would people see this as a good place for a deviation from MISRA rule 7.1?]]></description>
			<content:encoded><![CDATA[MISRA rule 7.1 says don't use octal constants, and gives good reasons.<br />
But code which sets and uses constants which represent Linux file permissions (see, for example, <a href="http://www.zzee.com/solutions/linux-permissions.shtml#numeric" target="_blank" rel="noopener" class="mycode_url">http://www.zzee.com/solutions/linux-perm...ml#numeric</a>), are necessarily octal and code is more readable in that case in octal -- the "native" format for such constants.<br />
<br />
Of course an octal number can be written, with the same digits, as hexadecimal, and that would meet the MISRA constraint. But IMHO would not meet the spirit of this rule, which is to avoid writing digits outside the base of the number by mistake. Writing a Linux file permissions constant as hex would mean that by mistake the developer could write a digit between 8 and F, and static analysis (compiler etc) would not catch it because it's legal hex. But illegal file permission digit.<br />
<br />
Would people see this as a good place for a deviation from MISRA rule 7.1?]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Rule 7.1 For Macro Arguments?]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=843</link>
			<pubDate>Mon, 12 Sep 2011 14:16:25 +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=843</guid>
			<description><![CDATA[Hi,<br />
<br />
Does rule 7.1, "Octal constants (other than zero) and octal escape sequences shall not be used", apply to function-like macro arguments? For example:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>#define MACRO(a)&nbsp;&nbsp;&nbsp;&nbsp;XYZ_##a<br />
<br />
int MACRO(01);</code></div></div><br />
Is the '01' argument to MACRO() a violation of this rule?]]></description>
			<content:encoded><![CDATA[Hi,<br />
<br />
Does rule 7.1, "Octal constants (other than zero) and octal escape sequences shall not be used", apply to function-like macro arguments? For example:<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>#define MACRO(a)&nbsp;&nbsp;&nbsp;&nbsp;XYZ_##a<br />
<br />
int MACRO(01);</code></div></div><br />
Is the '01' argument to MACRO() a violation of this rule?]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[What about '\\0'?]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=17</link>
			<pubDate>Wed, 08 Dec 2004 21:03:37 +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=17</guid>
			<description><![CDATA[Does Rule 7.1, \"No octal constants (other than zero) and octal escape sequences shall not be used,\" permit the use of the null character, '\\0'?  The normative and rule text exempt 0, per se, but make no mention about '\\0'.  Prohibitting '\\0' runs, IMHO, contrary to the Principle of Least Surprise.  Perhaps someone would show such kindness as to provide me with some clarity?<br />
<br />
I appreciate your time in advance.]]></description>
			<content:encoded><![CDATA[Does Rule 7.1, \"No octal constants (other than zero) and octal escape sequences shall not be used,\" permit the use of the null character, '\\0'?  The normative and rule text exempt 0, per se, but make no mention about '\\0'.  Prohibitting '\\0' runs, IMHO, contrary to the Principle of Least Surprise.  Perhaps someone would show such kindness as to provide me with some clarity?<br />
<br />
I appreciate your time in advance.]]></content:encoded>
		</item>
	</channel>
</rss>