The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: jj2007 on March 28, 2008, 10:18:36 PM

Title: Problem with structure in structure
Post by: jj2007 on March 28, 2008, 10:18:36 PM
I stumbled over error A2181: initializer must be a string

This is the structure that triggers the error:
JSEL STRUCT
  chrg CHARRANGE <>
  fvl DWORD ?
JSEL ENDS


However, if I change the order, it works:

JSEL STRUCT
  fvl DWORD ?
  chrg CHARRANGE <> ; as last item, it works
JSEL ENDS


Any explanation?
Title: Re: Problem with structure in structure
Post by: xmetal on March 29, 2008, 03:45:29 AM
I'm almost certain the source of the error is somewhere "around" (above?) the declaration of the structure itself. Use the /Fl and /Sa options with ml to investigate.

Both cases work in my tests.
Title: Re: Problem with structure in structure
Post by: MichaelW on March 29, 2008, 03:45:59 AM
It works for me, and a similar structure defined in windows.inc (Version 1.4c BETA 20 July 2007) also works:

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    include \masm32\include\masm32rt.inc

    JSEL STRUCT
      chrg  CHARRANGE <>
      fvl   DWORD ?
    JSEL  ENDS

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    .data
      jsel  JSEL <>
      tr    TEXTRANGEA <>
    .code
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
start:
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    mov jsel.chrg.cpMin, 1
    mov jsel.chrg.cpMax, 2
    mov jsel.fvl, 3

    mov tr.chrg.cpMin, 1
    mov tr.chrg.cpMax, 2
    mov tr.lpstrText, 3

    inkey "Press any key to exit..."
    exit
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
end start

TEXTRANGEA STRUCT
  chrg          CHARRANGE <>
  lpstrText     DWORD      ?
TEXTRANGEA ENDS

Title: Re: Problem with structure in structure
Post by: jj2007 on March 29, 2008, 08:30:02 AM
I found the reason:

js   JSEL 10 dup (<?>)    throws the error

js   JSEL 10 dup (<>)     works fine

Thanks to both of you for pushing me into the right direction.