core/com.nokia.carbide.cpp.compiler.doc.user/html/errors/err_unused_args.htm
author timkelly
Thu, 10 Dec 2009 13:45:47 -0600
branchRCL_2_4
changeset 671 80524b72f957
parent 0 fb279309251b
child 1641 2b3996fc09a1
permissions -rw-r--r--
Add S60 5.2 support.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta name="LASTUPDATED" content="06/17/05 11:09:43" />
<title>Unused Arguments</title>
<link rel="StyleSheet" href="../../book.css" type="text/css"/>
</head>
<body bgcolor="#FFFFFF">
<h3>Unused Arguments</h3>
<p>  If you enable the Unused Arguments setting, the compiler generates a warning when it encounters an argument you declare but do not use. This check helps you find arguments that you either misspelled or did not use in your program.</p>
<p class="listing">void foo(int temp,int errer); // ERROR: errer is misspelled<br />
  {<br />
  error = do_something(); // WARNING: temp and error are<br />
  // unused.<br />
} </p>
<p>You can declare an argument that you do not use in two ways without receiving this warning:</p>
<ul>
  <li>Use the pragma unused, as in this example:</li>
</ul>
<blockquote>
  <p class="listing">void foo(int temp, int error)<br />
    {<br />
    #pragma unused (temp)<br />
    /* Compiler does not warn that temp is not used */<br /> 
    error=do_something();<br />
  }</p>
</blockquote>
<ul>
  <li>Disable the <a href="../pragmas/p_ANSI_strict.htm">ANSI Strict</a> setting and do not give the unused argument a name. (See <a href="../c_compiler/c_unnamed_args.htm">Unnamed Arguments in Function Definitions</a>.) An example of Unused, Unnamed Arguments:</li>
</ul>
<blockquote>
  <p class="listing">void foo(int /* temp */, int error)<br />
    {<br />
    /* Compiler does not warn that &quot;temp&quot; is not used.<br />
    error=do_something(); */<br />
    }</p>
</blockquote>
<p>The Unused Arguments setting corresponds to the pragma warn_unusedarg, described at <a href="../pragmas/p_warn_unusedarg.htm">warn_unusedarg</a>. To check this setting, use <span class="code">__option (warn_unusedarg)</span>.</p>
<p> See <a href="../symbols/sym_settings.htm">Checking Option Settings</a> for information on how to use this directive.<br />
</p>
<div id="footer">Copyright &copy; 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. <br>License: <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a></div>


</body>
</html>