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
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
You should be declaring it like
hwnd HWND ?
wc WNDCLASSEX <>
msg MSG <>
As MSG and WNDCLASSEX are all structs.
hwnd HWND ?
wc WNDCLASSEX <>
msg MSG <>
As MSG and WNDCLASSEX are all structs.
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
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
Don't worry about that. We were all once a beginner. Do ask questions if you are unsure about anything.
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?
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?
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.