[RFC] Signed/unsigned character arrays are not strings
Mark Kettenis
mark.kettenis@xs4all.nl
Thu Mar 1 11:01:00 GMT 2007
> Date: Tue, 27 Feb 2007 20:51:54 -0500
> From: <pkoning@equallogic.com>
>
> > Okay, here's a horrible idea. :) With this patch:
> >
> > $ cat chars.c
> > #include <stdio.h>
> > #include <stdint.h>
> >
> > typedef char byte_t;
> >
> > char *c = "chars";
> > unsigned char *uc = "unsigned chars";
> > signed char *sc = "signed chars";
> > byte_t *b = "bytes";
> > int8_t *i8 = "int8_t's";
> > uint8_t *ui8 = "uint8_t's";
>
> Neat.
>
> I would tweak it a little. People might be using typedefs
> for character strings that wrap, say, "unsigned char".
> So if you're going to do a heuristic on the name, treat
> it as a character string if the name ends in "char" (not
> necessarily with a preceding space) or "char_t" (because
> many people use _t as the suffix for typedef names).
I think this is a bad idea. These choices are pretty arbitrary; isn't
"string" a reasonable name for a character string typedef too. And
then of course you'd need to add "string_t" too. Really, if we're
going to have a list of types, I think it should be a list of types
for which we are not going to print the result as a string. And it
should only include typedefs mentioned in the relevant language
standard.
Oh and of course POSIX explicitly reserves the _t suffix, so people
really should not be naming their types "char_t".
Mark
More information about the Gdb
mailing list