I'm wondering how I can initialize a STRUCT when assembling in Visual Studio 2015 without getting an error.
The following code works in quick editor but gets an A2008 error in Visual Studio because of the angled brackets to initialize the struct:
.386
.model flat, stdcall
.stack 4096
.data
hFile dd 0
htest MODULEENTRY32 <>
.code
main:
end main
Try
htest MODULEENTRY32 <?>
Take a look at https://msdn.microsoft.com/en-us/library/afzk3475.aspx?f=255&MSPPError=-2147217396
And this one : http://people.sju.edu/~ggrevera/arch/references/MASM61PROGUIDE.pdf
<?> has the same issue
It is initialized correctly to get the default initializers, so I'm not sure why this error occurs in visual studio. It seems like that syntax isn't allowed in VS, but I need to use it.
Quote from: Nickmare on January 23, 2016, 06:09:44 AM
The following code works in quick editor but gets an A2008 error in Visual Studio because of the angled brackets to initialize the struct
The initialization is OK - make sure that the structure is declared (by using the corresponding includes).
Something you should not do is use the old DOS .STACK setting, in 32 bit PE files that stack size is set by the linker. Sorry but I don't use VC/VS so I personally cannot help you with the structure notation. Just make sure you have the structure in the include file you use in VC/VS.
QuoteITEMS STRUCT
Iname BYTE 'Item Name'
Inum WORD ?
UNION ITYPE ; UNION keyword appears first
oldtype BYTE 0 ; when nested in structure.
newtype WORD ? ; (See "Nested Structures
ENDS ; and Unions," following ).
ITEMS ENDS
.
.
.
.DATA
Item1 ITEMS < > ; Accepts default initializers
Item2 ITEMS { } ; Accepts default initializers
Item3 ITEMS <'Bolts', 126> ; Overrides default value of first
; 2 fields; use default of
; the third field
Item4 ITEMS { \
'Bolts', ; Item name
126 \ ; Part number
}
Page 98 of the pdf link I send below (MASM 6.1 Manual)