Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Kulin <remailer@reece.net.au> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: typedef struct |
| Date | 2012-05-31 19:10 +0000 |
| Organization | Kulin Remailer |
| Message-ID | <FU7C4MOD41061.1321296296@reece.net.au> (permalink) |
| References | <lnk485rg3o.fsf@nuthaus.mib.org> |
Keith Thompson <kst-u@mib.org> wrote:
> John McDermick <johnthedspguy@gmail.com> writes:
> > If I have this definition in a header file:
> >
> > typedef struct A
> > {
> > int test;
> > } B;
> >
> > What exactly is A and what is B ?
What if I want to create a pointer to the struct inside the struct?
typedef struct A {
A *p1; /* not allowed */
B *p2; /* not allowed */
} B;
This gives compilation errors. Is it possible to create a pointer to the
struct being defined, within the struct, using the original typedef and
thereby not having to code 'struct' to define the pointer?
> struct A {
> struct A *p;
> };
> and then refer to it as "struct A". There's no real need to use a
> typedef to give the type another name; it already has a perfectly good
> one.
>
> (The counterargument is that many people like to have a one-word name
> for the type.)
My desire is simply to avoid having to create pointers as struct * inside
the structure. Other than that I would tend to agree.
Back to comp.lang.c | Previous | Next — Next in thread | Find similar | Unroll thread
Re: typedef struct Kulin <remailer@reece.net.au> - 2012-05-31 19:10 +0000
Re: typedef struct Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-05-31 15:14 -0400
Re: typedef struct Nomen Nescio <nobody@dizum.com> - 2012-06-01 02:50 +0200
Re: typedef struct 张源 西北工业大学 <zhabgyuan1993@gmail.com> - 2012-06-08 10:02 -0700
Re: typedef struct Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-06-08 13:20 -0400
Re: typedef struct 张源 西北工业大学 <zhabgyuan1993@gmail.com> - 2012-06-08 10:27 -0700
Re: typedef struct Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-06-08 13:32 -0400
Re: typedef struct 张源 西北工业大学 <zhabgyuan1993@gmail.com> - 2012-06-08 10:37 -0700
Re: typedef struct Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-06-08 13:55 -0400
Re: typedef struct Zhang Yuan <zhabgyuan1993@gmail.com> - 2012-06-08 11:22 -0700
Re: typedef struct James Kuyper <jameskuyper@verizon.net> - 2012-06-08 14:35 -0400
Re: typedef struct Zhang Yuan <zhabgyuan1993@gmail.com> - 2012-06-08 11:41 -0700
Re: typedef struct Keith Thompson <kst-u@mib.org> - 2012-06-08 14:22 -0700
Re: typedef struct Zhang Yuan <zhabgyuan1993@gmail.com> - 2012-06-08 18:28 -0700
Re: typedef struct Zhang Yuan <zhabgyuan1993@gmail.com> - 2012-06-08 11:08 -0700
Re: typedef struct Xavier Roche <xroche@free.fr.NOSPAM.invalid> - 2012-05-31 21:14 +0200
Re: typedef struct 张源 西北工业大学 <zhabgyuan1993@gmail.com> - 2012-06-08 10:20 -0700
Re: typedef struct James Kuyper <jameskuyper@verizon.net> - 2012-06-08 14:31 -0400
Re: typedef struct Zhang Yuan <zhabgyuan1993@gmail.com> - 2012-06-08 11:45 -0700
Re: typedef struct James Kuyper <jameskuyper@verizon.net> - 2012-06-08 15:10 -0400
Re: typedef struct Zhang Yuan <zhabgyuan1993@gmail.com> - 2012-06-08 12:27 -0700
Re: typedef struct Zhang Yuan <zhabgyuan1993@gmail.com> - 2012-06-08 11:48 -0700
Re: typedef struct Keith Thompson <kst-u@mib.org> - 2012-05-31 14:24 -0700
Re: typedef struct Nomen Nescio <nobody@dizum.com> - 2012-06-01 10:20 +0200
Re: typedef struct Keith Thompson <kst-u@mib.org> - 2012-06-01 11:45 -0700
Re: typedef struct Ian Collins <ian-news@hotmail.com> - 2012-06-02 07:52 +1200
Re: typedef struct Ike Naar <ike@sverige.freeshell.org> - 2012-06-01 21:54 +0000
Re: typedef struct "BartC" <bc@freeuk.com> - 2012-06-01 23:36 +0100
Re: typedef struct Fritz Wuehler <fritz@spamexpire-201206.rodent.frell.theremailer.net> - 2012-06-02 23:31 +0200
Re: typedef struct Keith Thompson <kst-u@mib.org> - 2012-06-02 18:30 -0700
Re: typedef struct Robert Miles <milesrf@Usenet-News.net> - 2012-06-29 16:29 -0500
Re: typedef struct Keith Thompson <kst-u@mib.org> - 2012-06-29 14:58 -0700
Re: typedef struct Robert Miles <milesrf@Usenet-News.net> - 2012-07-01 22:55 -0500
Re: typedef struct Keith Thompson <kst-u@mib.org> - 2012-07-01 23:00 -0700
Re: typedef struct James Kuyper <jameskuyper@verizon.net> - 2012-07-02 07:12 -0400
csiph-web