Please help !!
How do I define a self-referencing structure as below MeshFrame struct
... has fields which are pointers to objects of the same type.
I would normally just define them as dwords...
Is there a better way?


;Quick rip of the mframe.h file, from m$'s AnimatedMesh example.
;-Animation key data, used by the MeshFrame structure
;-----------------------------------------------------------------------------------

;XFile key versions
SRotateKeyXFile STRUCT
dwTime DWORD ?
dwFloats DWORD ?
w FLOAT ?
x FLOAT ?
y FLOAT ?
z FLOAT ?
SRotateKeyXFile ENDS

PALETTESIZE EQU 8

SScaleKeyXFile STRUCT
dwTime DWORD ?
dwFloats DWORD ?
vScale D3DXVECTOR3 <>
SScaleKeyXFile ENDS

SPositionKeyXFile STRUCT
dwTime DWORD ?
dwFloats DWORD ?
vPos D3DXVECTOR3 <>
SPositionKeyXFile ENDS

SMatrixKeyXFile STRUCT
dwTime DWORD ?
dwFloats DWORD ?
mat D3DXMATRIX <>
SMatrixKeyXFile ENDS

;in memory versions, used by sframe
RotateKey STRUCT
dwTime DWORD ?
quatRotate D3DXQUATERNION <>
RotateKey ENDS
typedef LPROTATEKEY:ptr RotateKey

PositionKey STRUCT
dwTime DWORD ?
vPos D3DXVECTOR3 <>
PositionKey ENDS
typedef LPPOSITIONKEY:ptr PositionKey

ScaleKey STRUCT
dwTime DWORD ?
vScale D3DXVECTOR3 <>
ScaleKey ENDS
typedef LPSCALEKEY:ptr ScaleKey

MatrixKey STRUCT
dwTime DWORD ?
mat D3DXMATRIX <>
MatrixKey ENDS
typedef LPMATRIXKEY:ptr MatrixKey

;-----------------------------------------------------------------------------------
;SkinnedAnimatedMeshFrameLL container-object modified from m$ example's SFrame object :D

MeshFrame STRUCT
LO LINKEDOBJECT <> ;Standard LL object header - contains nameptr,linkptrs etc
pmcMesh PTR SMeshContainer ;fix this
matRot D3DXMATRIX <>
matTrans D3DXMATRIX <>
matRotOrig D3DXMATRIX <>
matCombined D3DXMATRIX <>
m_iLastKey DWORD ?
; // animation information
m_pPositionKeys LPPOSITIONKEY ?
m_cPositionKeys DWORD ?
m_pRotateKeys LPROTATEKEY ?
m_cRotateKeys DWORD ?
m_pScaleKeys LPSCALEKEY ?
m_cScaleKeys DWORD ?
m_pMatrixKeys LPMATRIXKEY ?
m_cMatrixKeys DWORD ?
pframeAnimNext LPMFRAME ?
pframeToAnimate LPMFRAME ?
; pframeSibling LPMFRAME ? ;Redundant - use LinkedObject header field

pframeFirstChild LPMFRAME ? ;Object keeps pointer to its Oldest Child
bAnimationFrame DWORD ? ;Boolean flag
; szText ;Redundant - use LO header field
MeshFrame ENDS
typedef LPMFRAME:ptr MeshFrame
Posted on 2002-09-03 03:09:11 by Homer
I honestly do not think that is even possible, i mean what whould the assembler or compiler do?

STRUC My_Test
field1 dd ?
field2 My_Test <?>
filed3 dd ?
ENDS

He needs the size of My_test to decide the relative address of field3 in the structure and that can not be resolved even if it makes one additional or many passes... this can not be resolved pure and simple...

So IMHO its just a reference to a structure of that kind inside like this

DWORD typedef lpMY_TEST_STRU

STRUC my_Test
field1 dd ?
field2 lpMY_TEST_STRU ?
field3 dd ?
ENDS

well the exact syntax might be diferent but you get the point...

Indeed i whould just define them as DWORDS and make a comment note showing its a "lp_something"

Bogdan
Posted on 2002-09-05 03:18:28 by BogdanOntanu
Thanks for your reply.
I seem to recall reading somewhere that masm was not capable of forward referencing, thanks, I'll just stick to defining them as DWORDS and deal with them in the procs that use them, as normal.
I was just hoping against hope that maybe somebody knew different.
Posted on 2002-09-05 07:05:57 by Homer
I am not sure for MASM but TASM sure can use forward references, i use them all the time, and singe TASM is older than MASM i guess MASM can also...

Just that the above problem is impossible to be resolved anyway by any humman and/or compiler on Earth ... If i understand it corectly ...that is...
Posted on 2002-09-10 16:04:21 by BogdanOntanu
pMySillyStruc TYPEDEF PTR MySillyStruc


MySillyStruc STRUCT
me pMySillyStruc ?
myself pMySillyStruc ?
I pMySillyStruc ?
MySillyStruc ENDS
:alright: In real code MASM doesn't appear to use all this great type checking information generated by thoughtful programmers - personally I still try to use PTR when I can.
Posted on 2002-09-10 22:41:06 by bitRAKE
Many thanks BitRake - it works :alright:
Stronger typechecking - and it looks much nicer too :tongue:
Posted on 2002-09-13 23:01:00 by Homer