Re: A basic (?) problem with addresses (gcc)
- From: "BartC" <bc@xxxxxxxxxx>
- Date: Thu, 16 Dec 2010 20:12:18 -0000
"Seebs" <usenet-nospam@xxxxxxxxx> wrote in message
news:slrnigkle6.26q4.usenet-nospam@xxxxxxxxxxxxxxxxxx
On 2010-12-16, BartC <bc@xxxxxxxxxx> wrote:OK. But apart from the inconvenience of wrapping these things in unions
then
having to use field selection to access the data, how do you do something
like this:
integer*4 i(20)
real*8 a
equivalance (a,i(7))
(So the 8 bytes at i(7..8) are shared with the floating point number.)
You don't. C doesn't support or allow for overlap like this, so far as I
know.
The Fortran example was to demonstrate what I meant. But in fact I use that
construction in another language, and it looks like this:
[20]int i
real a @ &i[7]
(although actual uses are usually more straightforward).
From time to time it might be necessary to rewrite that in C, and I reliedon the OP's trick to do the conversion. Now it seems that that may not work,
not because there's some weird hardware involved, but because some compilers
might exploit a 'loophole' in the standard so that they can get away with a
cheap optimisation, even thought the hardware wouldn't have a problem with
it.
That sounds wrong. It also seems like something that C ought to be capable of: directly specifying an address where you want something stored, even if relative to the address of another object.
--
Bartc
.
- Follow-Ups:
- Re: A basic (?) problem with addresses (gcc)
- From: Jens Thoms Toerring
- Re: A basic (?) problem with addresses (gcc)
- References:
- A basic (?) problem with addresses (gcc)
- From: Piotrne
- Re: A basic (?) problem with addresses (gcc)
- From: Seebs
- Re: A basic (?) problem with addresses (gcc)
- From: BartC
- Re: A basic (?) problem with addresses (gcc)
- From: jacob navia
- Re: A basic (?) problem with addresses (gcc)
- From: Keith Thompson
- Re: A basic (?) problem with addresses (gcc)
- From: BartC
- Re: A basic (?) problem with addresses (gcc)
- From: Keith Thompson
- Re: A basic (?) problem with addresses (gcc)
- From: BartC
- Re: A basic (?) problem with addresses (gcc)
- From: Seebs
- A basic (?) problem with addresses (gcc)
- Prev by Date: Re: More on debuggers
- Next by Date: Re: Lowest addressed character in array
- Previous by thread: Re: A basic (?) problem with addresses (gcc)
- Next by thread: Re: A basic (?) problem with addresses (gcc)
- Index(es):
Relevant Pages
|