Taras_96 <taras.di@[EMAIL PROTECTED]
> writes:
> 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'.
It allows you to declare (not define) struct x in other places where the
typedef is not visible. You won't be able to use struct x directly, but
you will be able to use pointers to objects of type struct x.
If that is not an issue in your code (e.g. a short program consisting of
a single compilation unit), you can drop the struct tag.
(it also allows you to refer to struct x within itself, e.g. if struct x
is intended to be an element in a linked list or a node in a tree, but
struct x in your example is empty...)
DES
--
Dag-Erling Smørgrav - des@[EMAIL PROTECTED]
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.


|