C Programming question ...
Steve Jardine
sjardine at acm.org
Mon Jan 12 15:00:46 PST 2009
Kevin is right. No declaration. But, a symbol is created that is used for creating a
pointer to memory of the appropriate size upon declaration.
typedef struct is_field field_t; <<== Messy...
Why not:
typedef struct {
int f_type;
int f_size;
int f_offset;
char f_name[MAXFIELDNAME];
} is_field;
is_field xyz;
xyz.f_size=16384; etc...
Steve
On Wed, 7 Jan 2009 08:55:46 -0800
"Kevin O'Gorman" <kogorman at gmail.com> wrote:
> On Wed, Jan 7, 2009 at 8:00 AM, Ben Duncan <bend at linux4ms.net> wrote:
> > On this example:
> >
> > struct is_field {
> > int f_type;
> > int f_size;
> > int f_offset;
> > char f_name[MAXFIELDNAME];
> > };
> > typedef struct is_field field_t;
> >
> >
> > Is the "typedef item field_t" being allocated or just declared?
> >
> > I know if I do a :
> >
> > struct is_field {
> > ...... } My_Struct
> >
> > then My_Struct is allocated
> >
> >
> > Thanks ...
>
> The typedef does not declare a thing, but a type. You can then use the type
> to declare (and possibly allocate) things. In this case, the new type
> is field_t.
> So you can use it in a declarations
> field_t fieldThing;
> Which I woruld prefer to the awkward alternative
> struct is_field otherThing;
>
> HTH
>
> ++ kevin
>
> >
> > --
> > Ben Duncan - Business Network Solutions, Inc. 336 Elton Road Jackson MS,
> > 39212
> > "Never attribute to malice, that which can be adequately explained by
> > stupidity"
> > - Hanlon's Razor
> >
> > _______________________________________________
> > Linux-users mailing list ( Linux-users at linux-sxs.org )
> > Unsub/Password/Etc: http://linux-sxs.org/mailman/listinfo/linux-users
> >
> > Need to chat further on this subject? Check out #linux-users on
> > irc.linux-sxs.org !
> >
>
>
>
> --
> Kevin O'Gorman, PhD
> _______________________________________________
> Linux-users mailing list ( Linux-users at linux-sxs.org )
> Unsub/Password/Etc:
> http://linux-sxs.org/mailman/listinfo/linux-users
>
> Need to chat further on this subject? Check out #linux-users on irc.linux-sxs.org !
>
More information about the Linux-users
mailing list