core/com.nokia.carbide.cpp.compiler.doc.user/html/cpp_compiler/cpp_ctrl_var_scope.htm
author stechong
Wed, 20 Oct 2010 11:19:31 -0500
changeset 2165 2a7b5eccb0bc
parent 1641 2b3996fc09a1
permissions -rw-r--r--
Keeping PlatSim internal only.

<!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>Controlling Variable Scope in for Statements</title>
<link rel="StyleSheet" href="../../book.css" type="text/css"/>
</head>
<body bgcolor="#FFFFFF">
<h3>Controlling Variable Scope in for Statements</h3>
<p>If you enable the Legacy for-scoping setting , the compiler generates an error when it encounters a variable scope issue that the ISO C++ standard disallows, but is allowed in the C++ language specified in <strong>The Annotated C++ Reference Manual</strong>.</p>
<p>With this option off, the compiler allows variables defined in a for statement to have scope outside the for statement.</p>
<div class="listing">
  <h4>Listing 1. Example of a Local Variable Outside a for Statement</h4>
  <p>for(int i=1; i&lt;1000; i++) { /* ... */ }<br />
    return i; // OK in ARM, Error in Carbide.c++</p>
</div>
<p>This setting corresponds to the pragma <a href="../pragmas/p_arm_conform.htm">ARM_conform</a>. To check this setting, use <span class="code">__option (ARM_conform)</span>. By default, this setting is <span class="code">off</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; 2010 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>