[Gllug] Pointer arithmetic with void *

Alain Williams addw at phcomp.co.uk
Wed Aug 14 15:51:32 UTC 2002


On Wed, Aug 14, 2002 at 04:35:57PM +0100, Tethys wrote:
> 
> >If gcc is allowing this, it is breaking the standard. Try compiling with
> >the -pedantic flag.
> 
> Using -pedantic is usually over the top even for a self confessed pedant
> like me. However even with -Wall -ansi -pedantic, gcc still only gives a
> warning, not an error. Still, it does at least notice it, which -Wall
> -ansi (my default warning level) doesn't.
> 
> >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.

For a small amount of extra effort today - while the code that you are writing
is fresh in your mind -- yes. If there is a porting problem on some strange
box in 2 years time, you may waste hours trying to find/fix this.

Doing it correctly is the long way round, but often the long term short cut.

-- 
Alain Williams

#include <std_disclaimer.h>

-- 
Gllug mailing list  -  Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug




More information about the GLLUG mailing list