News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

nasm/yasm question

Started by Mark_Larson, November 11, 2006, 02:47:59 PM

Previous topic - Next topic

Mark_Larson

  can you declare a structure as a field inside your structure in  yasm/nasm?   I tried to get it to work and it keeps giving me an error message

struct  FRED
   asdf: resd 1
endstruc

struct MYOTHERSTRUC
  fredStruc: FRED
endstruc


BIOS programmers do it fastest, hehe.  ;)

My Optimization webpage
htttp://www.website.masmforum.com/mark/index.htm

akane

In original nasm you cannot, but you can do a trick:
struct  FRED
.asdf  resd 1
endstruc

struct MYOTHERSTRUC
.fredStruc.asdf resd 1 ; inline FRED
.rcDraw.left   resd 1 ; inline RECT
.rcDraw.top    resd 1
.rcDraw.right  resd 1
.rcDraw.bottom resd 1
endstruc

Or, if you do not need to access FRED members - define it as space:
struct MYOTHERSTRUC
.fredStruc resb sizeof(FRED)
endstruc

where sizeof is defined as
%define sizeof(x) x %+ _size
just copy all FRED members and append "fredStruc." prefix to all. It could be done by extra macro that wraps the 'struct' macro, i didn't tried.