Ok.. cap in hand time again :

This is my STRUCT decleration in an .inc file :

BIF STRUCT

ih BITMAPINFOHEADER <>
colours RGBQUAD 16 dup (<0,0,0,0>)

BIF ENDS

Now I want to initialize such a structure in the .DATA section, And i want to override the default values for the BITMAPINFOHEADER with my own but accept the defaults for the 16 RGBQUADS,so I have tried this :

mdibtemp BIF {<SIZEOF mbidtemp.ih,BITMAPWIDTH,-BITMAPHEIGTH,1,4,0,0,0,0,16,16>,<>}

And this :

mdibtemp BIF {<SIZEOF mbidtemp.ih,BITMAPWIDTH,-BITMAPHEIGTH,1,4,0,0,0,0,16,16>}

And this :

mdibtemp BIF {SIZEOF mbidtemp.ih,BITMAPWIDTH,-BITMAPHEIGTH,1,4,0,0,0,0,16,16}

And various other failed attempts. MASM reports always reports :
error A2177: nested structure improperly initialized

How do I initialise it correctly folks ?

Thanks for your help,

CodeBug
Posted on 2003-01-09 06:40:49 by CodeBug
Well I dont know if you can predefine the structure in that way.
I think you need to set the structure inside the structure.
Although im not 100% shure that there is not other way.
BIF STRUCT

ih BITMAPINFOHEADER <SIZEOF BITMAPINFOHEADER ,BITMAPWIDTH,-BITMAPHEIGTH,1,4,0,0,0,0,16,16>
colours RGBQUAD 16 dup (<0,0,0,0>)
BIF ENDS
.data
mdibtemp BIF <>
Posted on 2003-01-09 07:18:59 by natas
natas,

Thanks for you reply.. but I'm sure I can do it.. taking from my pages of MASM programmers guide ( and here reproduced from http://webster.cs.ucr.edu/Page_TechDocs/MASMDoc )

Structures as Field Initializers

Initializers for structure variables must be enclosed in curly braces or angle brackets, but you can specify overrides with fewer elements than the defaults.


This example illustrates the use of default values with structures as field
initializers:

DISKDRIVES STRUCT
a1 BYTE ?
b1 BYTE ?
c1 BYTE ?
DISKDRIVES ENDS

INFO STRUCT
buffer BYTE 100 DUP (?)
crlf BYTE 13, 10
query BYTE 'Filename: ' ; String <= can override
endmark BYTE 36
drives DISKDRIVES <0, 1, 1>
INFO ENDS

info1 INFO { , , 'Dir' }

; Next line illegal since name in query field is too long:
; info2 INFO {"TESTFILE", , "DirectoryName"}

lotsof INFO { , , 'file1', , {0,0,0} },
{ , , 'file2', , {0,0,1} },
{ , , 'file3', , {0,0,2} }


To me, reading this.. I should be able to achieve my stated aim ?

CodeBug
Posted on 2003-01-09 09:02:25 by CodeBug
CodeBug,

in your example from webster.cs.ucr.edu the INFO structure contains a DISKDRIVES structure. Note that the DISKDRIVES structure had been declared before its use inside the INFO structure. I guess you need to do the same with your structures. First declare a structure for the 16 RGBQUADs:


BIFCOLOURS STRUCT

colours RGBQUAD 16 dup (< 0,0,0,0 >)

BIFCOLOURS ENDS

then use it in the declaration of the BIF struct:


BIF STRUCT

ih BITMAPINFOHEADER < >
colrs BIFCOLOURS < >

BIF ENDS

and now declare your variables just as you did:


.DATA

mdibtemp BIF { < SIZEOF BITMAPINFOHEADER,BITMAPWIDTH,-BITMAPHEIGTH,1,4,0,0,0,0,16,16 > }
;mdibtemp BIF { < SIZEOF BITMAPINFOHEADER,BITMAPWIDTH,-BITMAPHEIGTH,1,4,0,0,0,0,16,16 >, <> }

Both of these compile (but of course not at the same time).


By the way, I replaced the first member of mdibtemp as there was a typo in your original version:

mdibtemp BIF {<SIZEOF mbidtemp.ih, ...

Regards

Frank
Posted on 2003-01-09 10:06:26 by Frank
Thanks Frank !

Got it to work.. BUT.. I don't understand why I had to declare a 'STRUCTURE-of-16 (RGB QUADS)STRUCTURES, before I could use them in the final BIF structure ...

RGBQUAD is a standard win32 structure and by doing RGBQUAD 16 dup <>, am I not simply asking for 16 of these to be put into my BIF structure ?

Anyhow.. thanks.. your reply got me going anyhow.. I undestand a little bit more now !

Codebug
Posted on 2003-01-09 11:36:42 by CodeBug

RGBQUAD is a standard win32 structure and by doing RGBQUAD 16 dup <>, am I not simply asking for 16 of these to be put into my BIF structure ?


I would think so too, but MASM apparently doesn't. Expanding your initial BIF structure leads to this notation (as well as to 14 errors, as documented in the comments):


BIF STRUCT
ih BITMAPINFOHEADER < >
colours RGBQUAD < 0,0,0,0 >
RGBQUAD < 0,0,0,0 >
RGBQUAD < 0,0,0,0 > ; error A2005: symbol redefinition : rgbBlue
RGBQUAD < 0,0,0,0 > ; error A2005: symbol redefinition : rgbBlue
RGBQUAD < 0,0,0,0 > ; error A2005: symbol redefinition : rgbBlue
RGBQUAD < 0,0,0,0 > ; error A2005: symbol redefinition : rgbBlue
RGBQUAD < 0,0,0,0 > ; error A2005: symbol redefinition : rgbBlue
RGBQUAD < 0,0,0,0 > ; error A2005: symbol redefinition : rgbBlue
RGBQUAD < 0,0,0,0 > ; error A2005: symbol redefinition : rgbBlue
RGBQUAD < 0,0,0,0 > ; error A2005: symbol redefinition : rgbBlue
RGBQUAD < 0,0,0,0 > ; error A2005: symbol redefinition : rgbBlue
RGBQUAD < 0,0,0,0 > ; error A2005: symbol redefinition : rgbBlue
RGBQUAD < 0,0,0,0 > ; error A2005: symbol redefinition : rgbBlue
RGBQUAD < 0,0,0,0 > ; error A2005: symbol redefinition : rgbBlue
RGBQUAD < 0,0,0,0 > ; error A2005: symbol redefinition : rgbBlue
RGBQUAD < 0,0,0,0 > ; error A2005: symbol redefinition : rgbBlue
BIF ENDS

Surprisingly, I get no errors when I label each RGBQUAD with a unique name:


BIF STRUCT
ih BITMAPINFOHEADER < >
colour0 RGBQUAD < 0,0,0,0 >
colour1 RGBQUAD < 0,0,0,0 >
colour2 RGBQUAD < 0,0,0,0 >
colour3 RGBQUAD < 0,0,0,0 >
colour4 RGBQUAD < 0,0,0,0 >
colour5 RGBQUAD < 0,0,0,0 >
colour6 RGBQUAD < 0,0,0,0 >
colour7 RGBQUAD < 0,0,0,0 >
colour8 RGBQUAD < 0,0,0,0 >
colour9 RGBQUAD < 0,0,0,0 >
colourA RGBQUAD < 0,0,0,0 >
colourB RGBQUAD < 0,0,0,0 >
colourC RGBQUAD < 0,0,0,0 >
colourD RGBQUAD < 0,0,0,0 >
colourE RGBQUAD < 0,0,0,0 >
colourF RGBQUAD < 0,0,0,0 >
BIF ENDS

Here everything compiles nicely. But don't ask me why :-)

Frank
Posted on 2003-01-09 12:40:55 by Frank
Another MASM mystery then perhaps.

Cheers Frank !

Codebug
Posted on 2003-01-09 12:51:06 by CodeBug