Symbian3/PDK/Source/GUID-97C0A5B1-99AE-5F71-9092-A6976E54AEA7.dita
author Dominic Pinkman <Dominic.Pinkman@Nokia.com>
Thu, 11 Mar 2010 18:02:22 +0000
changeset 3 46218c8b8afa
parent 1 25a17d01db0c
child 5 f345bda72bc4
permissions -rw-r--r--
week 10 bug fix submission (SF PDK version): Bug 1892, Bug 1897, Bug 1319. Also 3 or 4 documents were found to contain code blocks with SFL, which has been fixed. Partial fix for broken links, links to Forum Nokia, and the 'Symbian platform' terminology issues.

<?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-97C0A5B1-99AE-5F71-9092-A6976E54AEA7" xml:lang="en"><title>How
to initialise STRUCT RESOURCE members</title><prolog><metadata><keywords/></metadata></prolog><conbody>
<p><i><codeph>&lt;struct-initialiser&gt;</codeph></i>
</p>
<p><b>struct-initialiser ::=</b>
    </p>
<p><i><codeph>&lt;struct-name&gt;</codeph></i><b> {</b> <i><codeph>&lt;struct-initialiser-item-list&gt;</codeph></i> <b>}</b> <i><codeph>&lt;struct-initialiser-item&gt;</codeph></i>
</p>
<p><b>struct-initialiser-item ::=</b>
    </p>
<p><i><codeph>&lt;member-name&gt; = &lt;initialiser&gt; ;</codeph></i></p>
<p>To initialise a member of <codeph>STRUCT</codeph> type, give the <varname>struct-name</varname> with
which you wish to initialise it, and then specify each member of that struct
which you wish to initialise.</p>
<p>The <varname>member-name</varname>s listed must be members of the <varname>struct-name</varname> struct.
Each <varname>initialise</varname> must be of a type compatible with the member
it is initialising.</p>
<p><b>Example</b> </p>
<p>Given the previously defined struct types,</p>
<codeblock id="GUID-B7A47237-F871-5A07-B97B-11034F7019D1" xml:space="preserve">STRUCT STRINGCOUNT
 {
 BUF message;
 WORD num;
 }</codeblock>
<codeblock id="GUID-562D9436-F734-5E07-B452-08BD40F08959" xml:space="preserve">STRUCT SAMPLE
 {
 WORD anynumber;
 STRUCT text; // should be a STRINGCOUNT 
 }</codeblock>
<p>the following example shows how to define the struct within a resource:</p>
<codeblock id="GUID-425AD6B0-750B-56C2-8643-2726904C7DB7" xml:space="preserve">RESOURCE SAMPLE show_how
 {
 anynumber=10;
 text=STRINGCOUNT
  {
  message="Hello"
  num=5;
  };
 }</codeblock>
<p><b>Type safety</b> </p>
<p>The compiler does not enforce type safety. Any struct can be used to initialise
a member declared to be of struct type. Usually, however, the designer of
the struct will have intended only one or a limited number of structs ever
be used to initialise a member. You should ensure that you initialise struct
members with the intended struct type.</p>
</conbody></concept>