olson@cuda.aaet.csc.ti.com (Doug Olson) (06/20/91)
I have a set of list processing functions that have the typedef typedef struct double_list { void *next; void *prev; char *key; } s_double_list; This is the structure that these functions manipulate. When structures are passed in they are treated as if they were s_double_list structures. The functions that call these list processing functions have structures such as typedef struct element { void *next; void *prev; char *name; int type; char *value; } s_element; typedef struct elem_buffer { void *next; void *prev; char *handle; int is_modified; int is_deleted; s_element *element_list; } s_elem_buffer; What I need to know is, how portable are the list processing functions. They are based on the assumption that the first three fields of the list structures will be void *, void * and char *. Is this a valid assumption? or can the order that fields are listed in a structure be changed by the compiler? -- ======================================================= Doug Olson | P.O. Box 149149, M/S 2227 Texas Instruments | Austin, Texas, 78714-9149 12501 Research Blvd | olson@aaet.csc.ti.com =======================================================
zvs@bby.oz.au (Zev Sero) (06/21/91)
DO> What I need to know is, how portable are the list processing DO> functions. They are based on the assumption that the first three DO> fields of the list structures will be void *, void * and char *. DO> Is this a valid assumption? or can the order that fields are DO> listed in a structure be changed by the compiler? `C compilers are constrained to assign components increasing memory addresses in a strict order, with the first component starting at the beginning address of the structure itself.' - H&S2 page 104 So the answer is, yes, they are portable (assuming that you have provided for the holes in the struct). -- Zev Sero - zvs@bby.oz.au `This constant intervention by government in tasks that belong to the individual must cease, or ours will become as bureaucratic a government as that of Russia.' - Senator Thomas Bayard, speaking on an animal inspection bill, 28 Apr 1884.