diff -r 000000000000 -r 89d6a7a84779 Symbian3/SDK/Source/GUID-0142B290-DA6C-5574-83D7-7555D804D9B5.dita --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Symbian3/SDK/Source/GUID-0142B290-DA6C-5574-83D7-7555D804D9B5.dita Thu Jan 21 18:18:20 2010 +0000 @@ -0,0 +1,75 @@ + + + + + +How +to initialise array RESOURCE members +

<array-initialiser>

+

array-initialiser ::=

+

{ <array-initialiser-item-comma-list> } <array-initialiser-item>

+

array-initialiser-item ::=

+

<initialiser>

+

Fixed-length arrays

+

If a member is declared as a fixed-length array in the STRUCT or RESOURCE definition, +for example,

+WORD elements[10] +

then you must not specify any more items than were given in the length.

+

If fewer items are specified in the default initialisation (i.e. in the STRUCT definition), +then an error also results.

+

Note that no values will be given to unspecified elements at the end of +the array, even if they have been default initialised in the STRUCT definition. +Take the following example:

+STRUCT SAMPLE + { + BYTE bts[3]={1,2,3}; + } +

In the following resource:

+RESOURCE SAMPLE default + {} +

the output will be the whole default array

+0x01 0x02 0x03 +

but in this resource:

+RESOURCE SAMPLE first_specified + { + bts={5}; + } +

the output is:

+0x05 +

with the second and third elements lost.

+

If you specify only the second element in the RESOURCE definition, +then the first element is taken from the default initialisation, the second +from the explicit initialisation and the third element is lost. The following +resource:

+RESOURCE SAMPLE second_specified + { + bts[1]=5; + } +

results in the 2-byte output:

+0x01 0x05 +

If, however, you explicitly initialise an element in the middle of an array +without having supplied default values for array members before it, then an +error will result.

+
Using expressions to initialise array elements

You +may initialise array elements with expressions. You must explicitly initialise +each member component of the array otherwise the expressions will be evaluated +incorrectly. The following resource:

RESOURCE SAMPLE correct_expression + { + bts[0]=3+1; + bts[1]=2; + bts[2]=3; + }

will generate the correct output 0x04 0x02 0x03. +However, if you use the following syntax:

RESOURCE SAMPLE incorrect_expression + { + bts={3+1,2,3}; + }

the output will be 0x03 0x02 0x03. This +is because the pre-processor treats 3+1 as a literal string +that is then interpreted by the compiler as 3. In the resource correct_expression above +the ‘=‘ sign forces the pre-processor to evaluate the expression.

+
\ No newline at end of file