Related articles |
---|
New datatype addition to gcc sriharsha.v@redpinesignals.com (Sriharsha Vedurmudi) (2004-12-11) |
Re: New datatype addition to gcc mrmnews@the-meissners.org (Michael Meissner) (2004-12-16) |
Re: New datatype addition to gcc sriharsha.v@redpinesignals.com (Sriharsha) (2004-12-16) |
Re: New datatype addition to gcc gneuner2@comcast.net (George Neuner) (2004-12-17) |
Re: New datatype addition to gcc mrmnews@the-meissners.org (Michael Meissner) (2004-12-19) |
Re: New datatype addition to gcc gah@ugcs.caltech.edu (glen herrmannsfeldt) (2004-12-22) |
Re: New datatype addition to gcc mrmnews@the-meissners.org (Michael Meissner) (2004-12-23) |
Re: New datatype addition to gcc henry@spsystems.net (2004-12-23) |
Re: New datatype addition to gcc nathan.moore@sdc.cox.net (Nathan Moore) (2005-03-24) |
From: | henry@spsystems.net (Henry Spencer) |
Newsgroups: | comp.compilers |
Date: | 23 Dec 2004 17:55:44 -0500 |
Organization: | SP Systems, Toronto, Canada |
References: | 04-12-052 04-12-069 04-12-093 04-12-098 |
Keywords: | GCC, architecture, comment |
Posted-Date: | 23 Dec 2004 17:55:44 EST |
glen herrmannsfeldt <gah@ugcs.caltech.edu> wrote:
>Structures are allowed to have padding for alignment.
But otherwise they are required to be contiguous, unfortunately.
What's more, there is a deeply-ingrained assumption that all objects
can be accessed as arrays of bytes.
>...Casting pointers to a different type and
>dereferencing them is not guaranteed to work, either.
Unfortunately, certain cases *are* guaranteed to work -- like casting
"struct foo *" to "unsigned char *" for purposes of doing I/O on it:
When a pointer to an object is converted to a pointer to a character
type, the result points to the lowest addressed byte of the object.
Successive increments of the result, up to the size of the object,
yield pointers to the remaining bytes of the object.
(C99, section 6.3.2.3, para. 7)
--
"Think outside the box -- the box isn't our friend." | Henry Spencer
-- George Herbert | henry@spsystems.net
[Kind of makes me wonder what rock someone's been living under if he designs
a chip with non-uniform memory and expects people to program it in C. -John]
Return to the
comp.compilers page.
Search the
comp.compilers archives again.