Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!snorkelwacker!spdcc!ima!haddock!karl From: karl@haddock.ima.isc.com (Karl Heuer) Newsgroups: comp.lang.c Subject: Re: Circular references in declerations Keywords: circular decleration Message-ID: <16058@haddock.ima.isc.com> Date: 28 Feb 90 20:50:17 GMT References: <973@philtis.cft.philips.nl> <677@mwtech.UUCP> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Cambridge, MA 02138-5302 Lines: 22 In article <677@mwtech.UUCP> martin@mwtech.UUCP (Martin Weitzel) writes: >By tradition (%), name spaces for struct- and union-tags (uy, sx) >are separated from the name space for typedef-s (X, Y), so you >could in fact write. > typedef union Y { ..... ; struct X *x; ..... } Y; > typedef struct X { ..... ; union Y *y; ..... } X; >I don't know, if I should recommend to choose the same name >as struct/union-tag *and* typedef-d name. If you fully understand >the background, it saves remembering 'which is which', but for >the 'non-gurus' it might obscure the facts. >(%): C++ breaks with this tradition: A struct- or union-tag is >*automatically* a type name. It is for this reason that I *always* use the same name for the tag and the typedef: it makes it more compatible with C++ usage. If I ever want to convert the declarations to C++, all I have to do is remove the explicit typedef, since C++ provides it automatically. And since it has been suggested that C-2001 might be a standardization of C++ rather than C (though I hope not), it seems useful to keep the code "close" to C++ when the cost is small. Karl W. Z. Heuer (karl@ima.ima.isc.com or harvard!ima!karl), The Walking Lint