This is takes from Iczelion tutorial 3

LOCAL wc:WNDCLASSEX
LOCAL msg:MSG
LOCAL hwnd:HWND

Where he declares some local variables (or at least space for them) on the stack.? I'm OK with that but I was wondering why he used local variables on the stack to hold these structures.

Iczelion points out that these local structures are just reserved space and must be initialised by the program - and so I was thinking it would be OK then just to declare them as uninitialised global variables instead, so I gave it a go ;)

Believing the best way to learn is to play around with things I've tried commenting these lines out and putting these lines in DATA? section

? ? ? ? wc WNDCLASSEX
? ? ? ? msg MSG
? ? ? ? hwnd HWND

But this does not give the result I expected - I get loads of error messages the main ones being for the above lines

C:\RadAsm\Masm\Projects\tut03a\tut03.asm(19) : error A2179: structure improperly initialized
C:\RadAsm\Masm\Projects\tut03a\tut03.asm(19) : error A2008: syntax error : in structure
C:\RadAsm\Masm\Projects\tut03a\tut03.asm(20) : error A2179: structure improperly initialized
C:\RadAsm\Masm\Projects\tut03a\tut03.asm(20) : error A2008: syntax error : in structure

the line hwnd HWND seems ok though....

This is baffling me - why does the assembler complain these structures are improperly initialised when they are in the DATA? area - as putting them on the stack as local variables means they are also uninitialised!


dicky

Posted on 2005-08-15 10:31:26 by dicky96
You should be declaring it like

hwnd HWND ?
wc WNDCLASSEX <>
msg MSG <>

As MSG and WNDCLASSEX are all structs.
Posted on 2005-08-15 10:37:39 by roticv
Thank you very much for the rapid reply? ;D

I did put a ? at the end of each line - forgot to post that above.

I knew it was a structure but I did not know the <> tells the assembler it's a structure (I assume that is the purpose of <>)

As a learner there is so much simple stuff? I don't know.

dicky

Posted on 2005-08-15 10:41:25 by dicky96
Don't worry about that. We were all once a beginner. Do ask questions if you are unsure about anything.
Posted on 2005-08-15 11:25:22 by roticv
Ahh OK thanks,

Just while on the topic - does Iczelion declare these as local variables just to illustrate the technique - or is there some other adavantage or gain in program efficiency?
Posted on 2005-08-15 11:36:34 by dicky96
Personally I have no idea why he did that. I would perfer the msg and wc to be declared as global variable. Local variables are useful in the sense that the scope is only within that function.
Posted on 2005-08-15 12:25:57 by roticv