This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: A case for `void *' for pointers to arbitrary (byte) buffers


   Date: Tue, 3 May 2005 16:23:52 -0400
   From: Daniel Jacobowitz <drow@false.org>

   > Why not use `xxx_byte *' instead of `void *'?
   > ---------------------------------------------
   > 
   > * It's nonstandard.  Why do we need a nonstandard type if a perfectly
   >   god standard type is available?
   > 
   > * It doesn't really solve the issue.  It only propagates the problem
   >   one level up or down.  Since `xxx_byte *' is nothing but a typedef
   >   for `unsigned char *', someone calling a functions with `xxx_byte *'
   >   as one of its arguments with a `char *' argument will suffer from
   >   the warning that raised this entire issue; `void *' breaks the chain
   >   immediately.

   I think that's a bad thing!  For the same reason that we use -Werror:
   where possible, we can let GCC enforce consistency within our source
   base.  Use of gdb_byte (as unsigned char) buys you the advantage that
   any other pointer type won't silently convert to it.

Ah, but these are supposed to be opaque blobs of memory.

   If you want to use a standard type, play the necessary autoconf games
   to acquire stdint.h.  Use uint8_t *.

That's an interesting suggestion.  It might take a few iterations to
get that right though.

Mark


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]