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