Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

nested STRUCT in MASM 6.14

163 views
Skip to first unread message

Randall Hyde

unread,
Oct 19, 2001, 8:01:03 AM10/19/01
to

"Tim Roberts" <ti...@probo.com> wrote in message
news:0ddvsts0kfd59ndcc...@4ax.com...
> Byron Young <bky...@cwnet.com> wrote:
>
> >The following code, assembled with MASM 6.14, generates the following:
> >error A2177: nested structure improperly initialized
> >The question is, how should THE_S1 be initialized properly?
> >
> >Thanks,
> >bky...@cwnet.com
> >
> >LISTING 1
> >.486
> >
> >THE_S2 STRUCT
> > a db 11 dup (?)
> > b db 7 dup(?)
> >THE_S2 ENDS
> >
> >THE_S1 STRUCT
> > a db 10 dup(?)
> > b db 6 dup(?)
> > ic THE_S2 12 dup({})
> >THE_S1 ENDS
> >
> >SEG2 SEGMENT USE32
> >dta THE_S1 10 dup({'0123456789','012345',{'ALPHA','ALPHA'}})
> >SEG2 ENDS
>
> Well, in theory, since "ic" is an ARRAY of structs, you need another level
> of nesting at that level. Plus, there is a problem with some (all?)
> versions of MASM such that if you initialize ANY element of an array or
> structure, you have to at least provide enough commas to account for ALL
> elements. Thus, I expected this to work:
>
> dta THE_S1 10 dup({'0123456789','012345',{{'ALPHA','ALPHA'},,,,,,,,,,,}})

According to the documentation, if the commas are not present MASM will
use the default values. However, there were no default values in the
original structure declaration, maybe this is what's needed to solve the
problem.

Randy Hyde.


Tim Roberts

unread,
Oct 22, 2001, 12:46:59 AM10/22/01
to
"Randall Hyde" <rh...@transdimension.com> wrote:

>Tim wrote:
>>
>> Well, in theory, since "ic" is an ARRAY of structs, you need another level
>> of nesting at that level. Plus, there is a problem with some (all?)
>> versions of MASM such that if you initialize ANY element of an array or
>> structure, you have to at least provide enough commas to account for ALL
>> elements. Thus, I expected this to work:
>>
>> dta THE_S1 10 dup({'0123456789','012345',{{'ALPHA','ALPHA'},,,,,,,,,,,}})
>
>According to the documentation, if the commas are not present MASM will
>use the default values. However, there were no default values in the
>original structure declaration, maybe this is what's needed to solve the
>problem.

No, I tried that, too. I explicitly defined every element nested all the
way to the bottom level, and still got the "improper nesting" error. I got
sucked in to this problem, and eventually spent more than an hour dinking
with various permutations. I now honestly believe this is just a MASM
limitation.

It would be amusing to have to use Visual C++ to define the static data in
an otherwise purely MASM application...
--
- Tim Roberts, ti...@probo.com
Providenza & Boekelheide, Inc.

0 new messages