<?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.17 Library introduction (C++)]]></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:26 +0000</pubDate>
		<generator>MyBB</generator>
		<item>
			<title><![CDATA[Should #17-0-2 include any non-function identifier?]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=717</link>
			<pubDate>Tue, 16 Mar 2010 14:11:45 +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=717</guid>
			<description><![CDATA[A discussion of a similar rule for MISRA C concluded the rule was meant to encompass any reserved identifier.  While MISRA C++ has excluded functions from this rule and placed their consideration under rule #17-0-3, no mention of standard types (e.g, clock_t) or any other non-function identifier is made as far as I can tell.  Should the rule include these also?]]></description>
			<content:encoded><![CDATA[A discussion of a similar rule for MISRA C concluded the rule was meant to encompass any reserved identifier.  While MISRA C++ has excluded functions from this rule and placed their consideration under rule #17-0-3, no mention of standard types (e.g, clock_t) or any other non-function identifier is made as far as I can tell.  Should the rule include these also?]]></content:encoded>
		</item>
		<item>
			<title><![CDATA[Confusion over rule 17-0-3]]></title>
			<link>https://forum.misra.org.uk/showthread.php?tid=570</link>
			<pubDate>Mon, 25 Aug 2008 19:43:28 +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=570</guid>
			<description><![CDATA[Hi,<br />
<br />
    For rule 17-0-3, I see only two scenarios where the guidelines permit overloading a standard library function.  (Note: I presume by 'overridden', the guidelines actually mean over 'overloaded', since only virtual member-functions may be 'overridden'.  Do correct me, if I err in that assessment.)<br />
<br />
    The first scenario involves the addition of parameters to the function.  The text<br />
<blockquote class="mycode_quote"><cite>Quote:</cite>However,	 it is permissible to overload the name to add new parameter types if the functionality is consistent with those of the original.</blockquote>
makes this statement prima facia true.<br />
<br />
    The second scenario involves replacing a parameter type with a non-library type, implied by the sentence<br />
<blockquote class="mycode_quote"><cite>Quote:</cite>It is permissible to add a new sqrt function for a type not present in the library.</blockquote>
<br />
Therefore, we find the following code compliant:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>// Standard library code, simplified for this discussion<br />
template&nbsp;&nbsp;class vector{};<br />
void memcpy( char *, char *, int );<br />
// Non-library code<br />
class A{};<br />
void memcpy( char *, char *, int, int );&nbsp;&nbsp;// Ok, extra parameter.<br />
void memcpy( A, char *, int );&nbsp;&nbsp;// Ok, non-library type for a parameter.</code></div></div><br />
Meanwhile the following would not (the above code is presumed given):<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>void memcpy( vector, char *, int );&nbsp;&nbsp;// !Ok, library type for a parameter.</code></div></div><br />
What of built-in types?  Technically, the built-ins are <span style="font-weight: bold;" class="mycode_b"><span style="font-style: italic;" class="mycode_i"><span style="text-decoration: underline;" class="mycode_u">not</span></span></span> part of the library.  They are <span style="font-style: italic;" class="mycode_i">built-in</span>.  So, would this could comply with the rule?  (The above, again presumed.)<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>void memcpy( char*, char *, long );</code></div></div><br />
If the two scenarios are the only ones permitted, a rule as straightforward as,<br />
<br />
<blockquote class="mycode_quote"><cite>Quote:</cite>Standard library functions shall not be overloaded, except to add parameters or to substitute a non-library type for any of the parameters.</blockquote>
One would expect, would have sufficed.<br />
<br />
The fact MISRA chose to provide a rationale requiring a longer logic train, <span style="font-style: italic;" class="mycode_i">implies</span> other scenarios are permitted.  However, as I mentioned, I cannot conceive of such at this moment.<br />
<br />
Additionally, the rationale makes no mention of how to handle standard library functions which include ellipses in there parameter lists.  How should programmers handle such situations?<br />
<br />
Lastly, the ISO C++ standard, 17.4.2.2 p2 (lib.using.linkage), states,<br />
<blockquote class="mycode_quote"><cite>Quote:</cite>It is implementation-defined whether a name from the Standard C library declared with external linkage has extern "C" or extern "C++" linkage.  It is recommended that an implementation use extern "C++" linkage for this purpose.</blockquote>
which <span style="font-style: italic;" class="mycode_i">recommends</span>, but does not require extern "C++" linkage.  Combine this fact with ISO C++, 7.5 p6 (dcl.link),<br />
<blockquote class="mycode_quote"><cite>Quote:</cite>At most one function with a particular name can have C language linkage.</blockquote>
and One must ask if such circumstances were considered in the drafting of this rule.  (I feel reasonably confident the circumstances were considered.  The wording of the rationale, simply put, does not make any suggestion one way or the other.)]]></description>
			<content:encoded><![CDATA[Hi,<br />
<br />
    For rule 17-0-3, I see only two scenarios where the guidelines permit overloading a standard library function.  (Note: I presume by 'overridden', the guidelines actually mean over 'overloaded', since only virtual member-functions may be 'overridden'.  Do correct me, if I err in that assessment.)<br />
<br />
    The first scenario involves the addition of parameters to the function.  The text<br />
<blockquote class="mycode_quote"><cite>Quote:</cite>However,	 it is permissible to overload the name to add new parameter types if the functionality is consistent with those of the original.</blockquote>
makes this statement prima facia true.<br />
<br />
    The second scenario involves replacing a parameter type with a non-library type, implied by the sentence<br />
<blockquote class="mycode_quote"><cite>Quote:</cite>It is permissible to add a new sqrt function for a type not present in the library.</blockquote>
<br />
Therefore, we find the following code compliant:<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>// Standard library code, simplified for this discussion<br />
template&nbsp;&nbsp;class vector{};<br />
void memcpy( char *, char *, int );<br />
// Non-library code<br />
class A{};<br />
void memcpy( char *, char *, int, int );&nbsp;&nbsp;// Ok, extra parameter.<br />
void memcpy( A, char *, int );&nbsp;&nbsp;// Ok, non-library type for a parameter.</code></div></div><br />
Meanwhile the following would not (the above code is presumed given):<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>void memcpy( vector, char *, int );&nbsp;&nbsp;// !Ok, library type for a parameter.</code></div></div><br />
What of built-in types?  Technically, the built-ins are <span style="font-weight: bold;" class="mycode_b"><span style="font-style: italic;" class="mycode_i"><span style="text-decoration: underline;" class="mycode_u">not</span></span></span> part of the library.  They are <span style="font-style: italic;" class="mycode_i">built-in</span>.  So, would this could comply with the rule?  (The above, again presumed.)<br />
<br />
<div class="codeblock"><div class="title">Code:</div><div class="body" dir="ltr"><code>void memcpy( char*, char *, long );</code></div></div><br />
If the two scenarios are the only ones permitted, a rule as straightforward as,<br />
<br />
<blockquote class="mycode_quote"><cite>Quote:</cite>Standard library functions shall not be overloaded, except to add parameters or to substitute a non-library type for any of the parameters.</blockquote>
One would expect, would have sufficed.<br />
<br />
The fact MISRA chose to provide a rationale requiring a longer logic train, <span style="font-style: italic;" class="mycode_i">implies</span> other scenarios are permitted.  However, as I mentioned, I cannot conceive of such at this moment.<br />
<br />
Additionally, the rationale makes no mention of how to handle standard library functions which include ellipses in there parameter lists.  How should programmers handle such situations?<br />
<br />
Lastly, the ISO C++ standard, 17.4.2.2 p2 (lib.using.linkage), states,<br />
<blockquote class="mycode_quote"><cite>Quote:</cite>It is implementation-defined whether a name from the Standard C library declared with external linkage has extern "C" or extern "C++" linkage.  It is recommended that an implementation use extern "C++" linkage for this purpose.</blockquote>
which <span style="font-style: italic;" class="mycode_i">recommends</span>, but does not require extern "C++" linkage.  Combine this fact with ISO C++, 7.5 p6 (dcl.link),<br />
<blockquote class="mycode_quote"><cite>Quote:</cite>At most one function with a particular name can have C language linkage.</blockquote>
and One must ask if such circumstances were considered in the drafting of this rule.  (I feel reasonably confident the circumstances were considered.  The wording of the rationale, simply put, does not make any suggestion one way or the other.)]]></content:encoded>
		</item>
	</channel>
</rss>