forward references in typedefs
George M. Jones
george at giza.cis.ohio-state.edu
Thu Jul 20 06:53:44 AEST 1989
I have noticed what I consider anomolous behavior when using forward references
in structs & typedefs and would would like to know whether things behave as
they do because (a) that's just the way the compilers choose to implement
a fuzzy point or (b) there is some definition (ansi, K&R) that say this is
[in]correct behavior.
The following code compiles (Sun, GCC, Green Hills) just fine as expected:
struct one
{
struct two_t *foo;
} one_t;
struct two
{
struct one_t *bar;
} two_t;
However all the compilers I tried appear to be choaking on the forward
reference to two_t in the following chunk of code
typedef struct one
{
two_t *foo;
} one_t;
typedef struct two
{
one_t *bar;
} two_t;
4:35pm> cc -c bad.c
"bad.c", line 3: syntax error at or near variable name "two_t"
"bad.c", line 4: zero sized structure
Any definitive answers from the knowledgable clientel of this newsgroup ?
Thanks,
---George Jones
-=-
OSU Computer & Inf. Science 2036 Neil Ave.,Columbus,Ohio 43210. 614-292-7325
george at cis.ohio-state.edu or ...!osu-cis!george
What would Christmas be without friends like you !
More information about the Comp.lang.c
mailing list