The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: rags on November 29, 2007, 06:33:30 PM

Title: C Struct questions
Post by: rags on November 29, 2007, 06:33:30 PM
Im converting some structs written in C to asm, and have a question concerning my understanding of them.

if I have a struct in C:

typedef struct row_list
    {
      int gc;
      int  z;
     }row_list;


I converted it to:
row_list STRUCT
      gc    dword       ?
      z     dword        ?
row_list ends


The struct in question is:
typedef struct col_list
    {
      int  lsize;
      int row_offset;
      struct  row_list *ptr;
     }col_list;


I have converted to:
col_list struct
 
      lsize        dword        ?
      row_offset   dword        ?
      pntr         dword        ?
col_list ends


I have very limited to non-existant knowledge of C.
Am I correct in understanding that this line in the second C struct: struct  row_list *ptr;
is just a pointer called ptr to the struct (first struct) called row_list, and thus can be defined as a dword?

any help would be appreciated. Thanks

Rags
Title: Re: C Struct questions
Post by: bozo on November 30, 2007, 03:25:54 AM
yes, you're right
Title: Re: C Struct questions
Post by: rags on November 30, 2007, 01:54:48 PM
Thank you very much Kernel!  :U
Title: Re: C Struct questions
Post by: donkey on November 30, 2007, 02:07:33 PM
whoops --- wrong thread :)

Donkey
Title: Re: C Struct questions
Post by: MazeGen on December 04, 2007, 02:47:19 PM
rags, you can do more explicit declaration in MASM:


prow_list TYPEDEF PTR row_list

col_list struct
      lsize        dword        ?
      row_offset   dword        ?
      pntr         prow_list    ?
col_list ends