Re: C programming on ARM
- From: David Brown <david@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 31 Jan 2008 12:12:17 +0100
Wilco Dijkstra wrote:
"CBFalconer" <cbfalconer@xxxxxxxxx> wrote in message news:47A11649.3D617492@xxxxxxxxxxxxWilco Dijkstra wrote:
... snip ...
My point was that the bitpatterns of all pointer types are theNot necessarily so. void* carries all the information, apart from
same for all addresses in the address space.
the object type. void* bitpattern is identical with the char*
bitpattern, but after that there are no limits.
You're talking about what the C language standards guarantee.
I'm talking about how compilers implement the language. On a
byte addressable architecture you can rely on the one I mentioned
above. The fact is most programs rely on this whether the standard
permits it or not...
It's a fair point that there is a difference what you can rely on for real, practical C and what the standards say. You can happily rely on things like 2's complement arithmetic, and data sizes being 8, 16, 32, 64 bits - if you are programming a dinosaur mainframe, you are probably aware of the fact!
And often when programming, you know exactly what compiler and target you are using, and can program accordingly rather than writing generic code.
However, you *can't* rely on pointers working like you describe in general - not in embedded programming. Aside from alignment problems (which may mean that using the pointer does not "just work", even if conversions back and forth do), there are many architectures with different pointer types and different memory spaces. These don't fit well with C (which expects a single memory space), but they are the reality we live with. On an AVR Mega256, a general flash pointer will 24 bits, while a ram pointer will be 16 bits. On some architectures you get "far" and "near" pointers. There are some that have a section of bit-addressable memory, with a different pointer type. You can't rely on these things having a consistent pointer size - you should not even rely on the C requirement of a "void *" supporting them all (embedded compilers don't always follow the standards if they conflict with generating good object code for real-world source code).
.
- Follow-Ups:
- Re: C programming on ARM
- From: Wilco Dijkstra
- Re: C programming on ARM
- References:
- C programming on ARM
- From: aamer
- Re: C programming on ARM
- From: Arlet Ottens
- Re: C programming on ARM
- From: Jim Relsh
- Re: C programming on ARM
- From: CBFalconer
- Re: C programming on ARM
- From: Paul Keinanen
- Re: C programming on ARM
- From: Hans-Bernhard Bröker
- Re: C programming on ARM
- From: Wilco Dijkstra
- Re: C programming on ARM
- From: Grant Edwards
- Re: C programming on ARM
- From: Wilco Dijkstra
- Re: C programming on ARM
- From: CBFalconer
- Re: C programming on ARM
- From: Wilco Dijkstra
- C programming on ARM
- Prev by Date: Re: C programming on ARM
- Next by Date: Re: Casting function pointers
- Previous by thread: Re: C programming on ARM
- Next by thread: Re: C programming on ARM
- Index(es):
Relevant Pages
|