Author Topic: STRUCT variable initialization  (Read 106 times)

aw27

  • Member
  • ****
  • Posts: 779
STRUCT variable initialization
« on: October 12, 2017, 07:33:31 PM »
myst1 does not cause an error, myst2 cause an error.
In MASM both cause the error:  error A2177:nested structure improperly initialized

Code: [Select]
thest0 struct
v1 dword ?
thest0 ends

thest1A struct
vv1 dword ?
vv2 thest0 2 dup(<>)
thest1A ends

thest1B struct
vv2 thest0 2 dup(<>)
vv1 dword ?
thest1B ends

.data
myst1 thest1A <?>
myst2 thest1B <?>



johnsa

  • Member
  • ****
  • Posts: 549
    • Uasm
Re: STRUCT variable initialization
« Reply #1 on: October 12, 2017, 10:30:19 PM »
I think this is sort of correct, in the case of myst1 the ? is applied to the dword and the nested struct has no initializers at all so is fine.
In the second case the in order initialisation requires a sub-structure of items to initialise the nested structure, which it doesn't have so fails.

Code: [Select]

myst1 thest1A <?> ;ok
myst2 thest1B <{<?>,<?>},?> ;ok
myst3 thest1B <?> ;fail


This is more feature than bug perhaps :)

aw27

  • Member
  • ****
  • Posts: 779
Re: STRUCT variable initialization
« Reply #2 on: October 12, 2017, 11:10:39 PM »
I thing that not putting there the "?" is the correct way.  :icon_rolleyes:
myst1 thest1A <>
myst2 thest1B <>

johnsa

  • Member
  • ****
  • Posts: 549
    • Uasm
Re: STRUCT variable initialization
« Reply #3 on: October 12, 2017, 11:14:44 PM »
yep that is also fine

Code: [Select]

myst4 thest1A <> ;ok
myst5 thest1B <> ;ok


no errors for that ?

aw27

  • Member
  • ****
  • Posts: 779
Re: STRUCT variable initialization
« Reply #4 on: October 12, 2017, 11:37:47 PM »
yep that is also fine

Code: [Select]

myst4 thest1A <> ;ok
myst5 thest1B <> ;ok


no errors for that ?
Works fine for UASM and MASM