| Deutsch English Français Italiano |
|
<4af4ce035c.DaveMeUK@BeagleBoard-xM> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: David Higton <dave@davehigton.me.uk>
Newsgroups: comp.sys.raspberry-pi
Subject: Re: Fscking Pointers.
Date: Wed, 26 Mar 2025 20:14:18 GMT
Organization: Home
Lines: 29
Message-ID: <4af4ce035c.DaveMeUK@BeagleBoard-xM>
References: <vs1jgs$2co6s$3@dont-email.me>
Injection-Date: Wed, 26 Mar 2025 21:14:30 +0100 (CET)
Injection-Info: dont-email.me; posting-host="b9a91ce9fb3fd11cd2f2a75cccf22739";
logging-data="2657447"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18XRubnJgwE+NdBznahJGFHDsEXcWl+uh4="
User-Agent: Messenger-Pro/8.03 (MsgServe/8.01) (RISC-OS/5.31) NewsHound/v1.55
Cancel-Lock: sha1:3/E558MvtehPQu43SU9FlpuNMiI=
Bytes: 2080
In message <vs1jgs$2co6s$3@dont-email.me>
The Natural Philosopher <tnp@invalid.invalid> wrote:
> It seems C has caught the disease of 'we will modify your code according
> to what WE think it means'..
>
> ..my pointers to 254 byte structures are going haywire when I add 256
> bytes to them...I have to add one instead... ..add that to the fact that to
> write to flash RAM you need to specify the *offset* from flash RAM base,
> but to read it you need to use the actual hardware address...
>
> sigh.
>
> What is the generic type for a simple pointer to presumably bytes, in ARM
> C? Or should I resign myself to doing everything in 256byte chunks? the
> structure to be read and written from Flash is exactly that big for
> obvious hardware reasons...
Pointers in C are incremented by the size of whatever they point to.
Yes, I've found it very frustrating in the past, too.
If you want to increment by one byte, you are clearly wanting to point
to something within the struct, so, point at the struct member rather
than the overall struct; and make sure that the member is amenable to
being addressed byte by byte. If necessary, create a union with a byte
array.
David