Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!tut.cis.ohio-state.edu!ucsd!chem.ucsd.edu!tps From: tps@chem.ucsd.edu (Tom Stockfisch) Newsgroups: comp.lang.c Subject: Re: questionnaire Message-ID: <650@chem.ucsd.EDU> Date: 13 Jan 90 02:30:27 GMT References: <1990Jan12.022039.15799@ux1.cso.uiuc.edu> Reply-To: tps@chem.ucsd.edu (Tom Stockfisch) Organization: Chemistry Dept, UC San Diego Lines: 45 In article <1990Jan12.022039.15799@ux1.cso.uiuc.edu> phil@ux1.cso.uiuc.edu (Phil Howard KA9WGN) writes: >I would like to find out from some different people what kinds of decisions >you typically make, and how you might make them regarding: >1. Whether or not to use "typedef" for a "struct" I define *all* structs as typedef struct FOO {...} FOO; Typedefs and struct tags belong to different identifier overload classes, so the same name may be used for both. Now you can say either struct FOO bar; or just FOO bar; > a. how do you deal with the case of two different struct types > having pointers to the other type? This method automatically takes care of this: struct FOO2; typedef struct FOO { struct FOO *next, *previous; ... struct FOO2 *buddy; } FOO; typedef struct FOO2 { struct FOO2 *next, *previous; ... struct FOO *buddy; } FOO2; >2. When you decide to separate structures into header files If you have two different source files which use the same struct, the struct definition better be in a header file which is included by both. Otherwise, I probably would keep it in the same file. -- || Tom Stockfisch, UCSD Chemistry tps@chem.ucsd.edu