Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | James Kuyper <jameskuyper@verizon.net> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: typedef struct |
| Date | 2012-06-08 15:10 -0400 |
| Organization | A noiseless patient Spider |
| Message-ID | <4FD24E43.60109@verizon.net> (permalink) |
| References | (1 earlier) <FU7C4MOD41061.1321296296@reece.net.au> <jq8fuq$a7u$2@news.httrack.net> <ff2eea74-12c7-49e3-aa6a-29ac842b3dd7@googlegroups.com> <4FD244E4.1000002@verizon.net> <245e351e-a24c-45c7-a740-701fad5cbe61@googlegroups.com> |
> On Saturday, June 9, 2012 2:31:00 AM UTC+8, James Kuyper wrote: >> On 06/08/2012 01:20 PM, 张源 西北工业大学 wrote: ... >> Being able to typedef incompletely is just a side effect of being able >> to declare an incomplete struct type: >> >> struct incomplete_type; >> struct another_incomplete_type *pointer_to_incomplete_type; >> >> The key point is that for some purposes there's no need to know the >> actual type of the struct. This is feasible because the standard >> requires that all pointers to structs have the same representation and >> alignment requirements, so you don't need to tell the compiler the exact >> type, so long as all you're doing is receiving pointers to the type, and >> passing them on to other functions that do know what the exact type is. > > thank you.i know a lot . > what do the same representation and alignment requirements mean? Every C object is stored in a series of bits; except for bit-fields, those bits usually fill up entire bytes. Every C type has an implementation-dependent mapping which connects bit patterns to values. That mapping is called the representation used by that type. Unsigned integer types have a simple binary representation. C signed integers have one of three types of representation: 1's complement, 2's complement, and sign-magnitude. They all store positive numbers the same way as the corresponding unsigned type, they differ only in the way they represent negative values. The C standard imposes no requirements on the representation of floating point types, but does say that if __STDC_IEC_559__ is pre-defined by the implementation, the implementation of floating point types should conform to the requirements of annex F, which details the ways in which they are required to conform to the requirements of IEEE/IEC 60559. Byte ordering (bigendian, littleendian, middleendian, etc.) is also part of the representation. The standard imposes no requirements on byte ordering. The C standard also says nothing about how pointers are represented. That's entirely up to the implementation. However, it does require that, in some cases, pointers to different types must be represented the same way. The alignment of a type is a requirement that objects of that type be allocated only at particular types of addresses. For instance, if an object may only be allocated at even addresses, it has an alignment requirement of 2. If it can only be allocated at addresses which are integer multiples of 4, it has an alignment requirement of 4.
Back to comp.lang.c | Previous | Next — Previous in thread | 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