[Gllug] Pointer arithmetic with void *
Jonathan Harker
jon at jonathanharker.co.uk
Wed Aug 14 16:03:01 UTC 2002
On Wednesday 14 Aug 2002 4:35 pm, you wrote:
> >If you want to do this sort of thing, you should cast via char*:
>
> Yes, that's what I've been doing up until now. I just wondered if it
> was strictly necessary.
Don't know much about C standard, but C++98 says you can't do pointer
arithmetic with void*. I imagine C99 would say the same. Best to avoid and
like Alain says, cast to (char*)
<ramble>
Just out of interest, I take it this is pretty low level stuff you're doing?
Playing with and casting void* can be dangerous! Is there a way you could
cast the void* that mmap returns directly to a struct?
eg.
some_struct* p;
p = mmap(....);
suppose not if you can't tell beforehand... </ramble>
:-)
Luv Jon
--
Gllug mailing list - Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug
More information about the GLLUG
mailing list