Symbian3/SDK/Source/GUID-6C1E4B3D-0FBF-5CEA-9A30-B4C5CB4CAC3E.dita
author Graeme Price <GRAEME.PRICE@NOKIA.COM>
Fri, 15 Oct 2010 14:32:18 +0100
changeset 15 307f4279f433
parent 0 89d6a7a84779
permissions -rw-r--r--
Initial contribution of the Adaptation Documentation.

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License 
"Eclipse Public License v1.0" which accompanies this distribution, 
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
    Nokia Corporation - initial contribution.
Contributors: 
-->
<!DOCTYPE concept
  PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept id="GUID-6C1E4B3D-0FBF-5CEA-9A30-B4C5CB4CAC3E" xml:lang="en"><title>Coding
literal descriptors</title><shortdesc>Literal descriptors must be defined in their own C++ statement
and the resulting constant used wherever it is required.</shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody>
<p> Literal descriptors cannot be embedded in expressions because they do
not create temporary objects.</p>
<p>Literal objects can be declared safely in header files:</p>
<ul>
<li id="GUID-1EEAF77A-63B1-5191-95D7-6F24FAC6B94C"><p>without requiring writable
data</p> </li>
<li id="GUID-BED08A91-2EAF-53CB-9B23-8F63D5658303"><p>without creating a copy
of the data in every module that includes the header.</p> </li>
</ul>
<p>Literals can be defined at file-scope, including in header files, in which
case they are visible to any code that follows. They can also be declared
local to the function which uses them. However, there are a couple of caveats
with defining them at function scope:</p>
<ul>
<li id="GUID-9193E180-8358-5BB9-8A76-5EAB4753FB4E"><p>For very short strings,
of the order of 3 ASCII characters or 1 UNICODE character, it is more efficient
to declare the literals at file scope.</p> </li>
<li id="GUID-CAEF761B-7E05-58C7-968E-FF9C31413FFB"><p>Literal descriptors
defined in inline functions are laid down in <i>every single</i> compilation
module that includes the header file.</p> </li>
</ul>
<p>Thus, if the descriptor is short or used only in an inline function, it
is better to define it at file scope with a suitably distinct name.</p>
</conbody></concept>