The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: angvelem on November 12, 2011, 07:22:58 PM

Title: Declaring a variable
Post by: angvelem on November 12, 2011, 07:22:58 PM
We have the following (MASM):

  TRACE_MAX    EQU 21

  TTrace STRUCT
    Coo        BASS_3DVECTOR <>
    Alpha    GLfloat ?
  TTrace ends

  TShapeTrace STRUCT
    Trace    TTrace TRACE_MAX dup (<>)
  TShapeTrace ends

.data?
  Shaper    TShapeTrace   701 dup (<>)  ; error


I can not understand how to properly describe the variable Shaper. Keep getting a message about an incorrect initialization of the structure. What is correct? I looked through all the sources for MASM, there is nothing similar.
Title: Re: Declaring a variable
Post by: jj2007 on November 12, 2011, 07:37:10 PM
Try this:
include \masm32\include\masm32rt.inc

  TRACE_MAX    EQU 21
BASS_3DVECTOR STRUCT
x dd ?
y dd ?
z dd ?
BASS_3DVECTOR ENDS

  TTrace STRUCT
    Coo       dd ? ; BASS_3DVECTOR <>
    Alpha    dd ? ;GLfloat ?
  TTrace ends

  TShapeTrace STRUCT
    Trace    TTrace TRACE_MAX dup (<>)
  TShapeTrace ends

.data?
  Shaper    TShapeTrace   701 dup (<>)  ; error
.code
AppName db "Masm32:", 0

start: MsgBox 0, "Hello World", addr AppName, MB_OK
exit

end start
Title: Re: Declaring a variable
Post by: angvelem on November 12, 2011, 07:53:26 PM
The same mistake:

...
.data?
  Shaper TShapeTrace   701 dup (<>)


error A2177: nested structure improperly initialized
Title: Re: Declaring a variable
Post by: jj2007 on November 12, 2011, 08:40:04 PM
Full example, but it will work only with JWasm. Don't ask me why ::)
include \masm32\include\masm32rt.inc

  TRACE_MAX    EQU 21
BASS_3DVECTOR STRUCT
x dd ?
y dd ?
z dd ?
BASS_3DVECTOR ENDS

  TTrace STRUCT
    Coo       BASS_3DVECTOR <>
    Alpha    REAL4 ? ; GLfloat ?
  TTrace ends

  TShapeTrace STRUCT
    Trace    TTrace TRACE_MAX dup (<>)
  TShapeTrace ends

.data?
  Shaper    TShapeTrace   701 dup (<>)  ; error
.code
AppName db "Masm32:", 0

start: MsgBox 0, "Hello World", addr AppName, MB_OK
exit

end start
Title: Re: Declaring a variable
Post by: angvelem on November 12, 2011, 09:13:47 PM
Alas, I only have MASM.
Title: Re: Declaring a variable
Post by: qWord on November 12, 2011, 10:15:14 PM
This a nasty bug!
Using a dummy structure may helps you:
  s STRUCT
    Trace    TTrace TRACE_MAX dup ({})
  s ends

  TShapeTrace STRUCT
    Trace    s <>
  TShapeTrace ends
...
Shaper    TShapeTrace   701 dup ({})
Title: Re: Declaring a variable
Post by: angvelem on November 12, 2011, 10:41:31 PM
Hooray, helped. Thank you.
Title: Re: Declaring a variable
Post by: jj2007 on November 12, 2011, 11:23:39 PM
Quote from: angvelem on November 12, 2011, 09:13:47 PM
Alas, I only have MASM.

http://www.japheth.de/JWasm.html#jwdownload - and you only need to replace \masm32\bin\ml.exe with jwasm.exe
Keep a copy of ml.exe, though - there are rare cases where Jwasm chokes over something.

qWord, is that a known Masm bug?
Title: Re: Declaring a variable
Post by: angvelem on November 12, 2011, 11:26:33 PM
I have already found their website and downloaded the JWASM.
Title: Re: Declaring a variable
Post by: angvelem on November 16, 2011, 07:16:20 PM
Quote from: jj2007 on November 12, 2011, 11:23:39 PM
http://www.japheth.de/JWasm.html#jwdownload - and you only need to replace \masm32\bin\ml.exe with jwasm.exe
Keep a copy of ml.exe, though - there are rare cases where Jwasm chokes over something.

Very bad compiler, include files from libraries BASS does not understand
Title: Re: Declaring a variable
Post by: jj2007 on November 16, 2011, 07:25:41 PM
Quote from: angvelem on November 16, 2011, 07:16:20 PM
Very bad compiler

It's called assembler, not compiler. And the problem might well be in your include files.
Title: Re: Declaring a variable
Post by: angvelem on November 16, 2011, 07:57:58 PM
It is you are talking to myself? Very noticeable on your behavior. Not respecting other, you do not respect yourself.

Removed the offending message? It means you are not quite yet lost man
Title: Re: Declaring a variable
Post by: angvelem on November 16, 2011, 08:04:17 PM
Include file is not my, he out of the library BASS.
Title: Re: Declaring a variable
Post by: qWord on November 16, 2011, 08:42:27 PM
Quote from: jj2007 on November 12, 2011, 11:23:39 PM

qWord, is that a known Masm bug?
Well, I know this error  :bg
IIRC there was also a discussion here ...
Title: Re: Declaring a variable
Post by: jj2007 on November 16, 2011, 09:21:16 PM
Quote from: qWord on November 16, 2011, 08:42:27 PM
IIRC there was also a discussion here ...

This one (http://www.masm32.com/board/index.php?topic=13125.0) or that one (http://www.masm32.com/board/index.php?topic=16283.msg134639#msg134639)?
Title: Re: Declaring a variable
Post by: qWord on November 16, 2011, 09:34:56 PM
Quote from: jj2007 on November 16, 2011, 09:21:16 PM
Quote from: qWord on November 16, 2011, 08:42:27 PM
IIRC there was also a discussion here ...

This one (http://www.masm32.com/board/index.php?topic=13125.0) or that one (http://www.masm32.com/board/index.php?topic=16283.msg134639#msg134639)?
no,
but I've found this one with exact the same problem:
http://www.masm32.com/board/index.php?topic=1700.0
Title: Re: Declaring a variable
Post by: jj2007 on November 16, 2011, 11:12:50 PM
Here (http://www.masm32.com/board/index.php?topic=13758.msg108161#msg108161) is another thread.

Another workaround - not elegant but it works:
.DATA?
car MOVER <>
REPEAT 9
MOVER <>
ENDM
Title: Re: Declaring a variable
Post by: qWord on November 16, 2011, 11:34:25 PM
Quote from: jj2007 on November 16, 2011, 11:12:50 PMAnother workaround - not elegant but it works
fortunately such structure configurations are very rare, thus this or any other workaround are acceptable  :P (?)
Title: Re: Declaring a variable
Post by: angvelem on November 17, 2011, 12:02:52 AM
Hmm, this option is also interesting.