Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C Moderated > typedef a struc...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 4 Topic 1079 of 1126
Post > Topic >>

typedef a struct

by Taras_96 <taras.di@[EMAIL PROTECTED] > Apr 16, 2008 at 04:56 PM

Hi everyone,

You can typedef a struct by using the following

typedef struct x {} X, *PX;

Now, I can understand the use of the typedefs, X and PX. They allow
you to declare the structs without having to use the struct keyword.
However, I'm not quite sure of the usefullness of the struct tag 'x'.

I seem to remember someone telling me that it had something to do with
resolving circular dependencies, when file A depends on file B, and
vice versa. Also, it may have something to do with structs that refer
to themselves (from the FAQ):

1.14:   I can't seem to define a linked list node which contains a
        pointer to itself.

A:      Structures in C can certainly contain pointers to themselves;
        the discussion and example in section 6.5 of K&R make this
        clear.  Problems arise if an attempt is made to define (and
use)
        a typedef in the midst of such a declaration; avoid this.

Could anyone shed some light on the usefulness of the struct tag 'x'?
-- 
comp.lang.c.moderated - moderation address: clcm@[EMAIL PROTECTED]
 -- you must
have an appropriate newsgroups line in your header for your mail to be
seen,
or the newsgroup name in square brackets in the subject line.  Sorry.
 




 4 Posts in Topic:
typedef a struct
Taras_96 <taras.di@[EM  2008-04-16 16:56:29 
Re: typedef a struct
Kenneth Brody <kenbrod  2008-04-18 16:11:33 
Re: typedef a struct
=?utf-8?Q?Dag-Erling_Sm=C  2008-04-18 16:11:41 
Re: typedef a struct
Taras_96 <taras.di@[EM  2008-04-21 13:18:40 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Jul 9 1:03:37 CDT 2008.