News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Nested structure initialisation

Started by Eugen, July 29, 2005, 11:20:16 AM

Previous topic - Next topic

Eugen

Hi all

I have problems declaring a nested structure. Here is a generic description of what i have:


struc_child STRUC
member1 dd ?
member2 dd ?
struc_child ENDS

struc_root STRUC
rmember1 dd ?
rmember2 dd ?
childs   struc_child 2 dup (<?>)
struc_root ENDS

.DATA

root1 struc_root <3,3,<44,33>,<11,55>>



I cant find a way to declare "root1" in order to assemble properly. I want to initialise all members of root1, all its members and all its childs. How do i declare it?

Thanks
Eugen


Tedd

The following appears to work okay..

struc_child STRUC
    member1 dd ?
    member2 dd ?
struc_child ENDS

struc_root STRUC
    rmember1 dd ?
    rmember2 dd ?
    child1   struc_child <?>
    child2   struc_child <?>
struc_root ENDS

;****************************************************************

.data
r1 struc_root <1,2,<3,4>,<5,6>>


The only actual difference is separating out 'childs' in struc_root.
No snowflake in an avalanche feels responsible.

Eugen

Hi Tedd,

Actualy, as i was saying, the code sample is generic, in reality "2 dup" is "10 dup" or more  :bg .
However, i found a way, not the best, but good enough:
Code:
struc_root STRUC
rmember1 dd ?
rmember2 dd ?
childs   struc_child <?>,<?>,<?>,...
struc_root ENDS

.DATA

root1 struc_root <3,3,{ <44,33>,<11,55>,... } >

funny is that i posted the question on win32asm forum also and i got the same answer  :bg , so i gave the same reply  :P

Anyway, thanks for the reply.

Eugen

Tedd

You may actually be much better off allocating the memory dynamically and storing your structures in that.
..just a thought :wink
No snowflake in an avalanche feels responsible.