[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Nmh-workers] Compiler warnings and signed vs. unsigned char, again
From: |
Tom Lane |
Subject: |
Re: [Nmh-workers] Compiler warnings and signed vs. unsigned char, again |
Date: |
Tue, 05 Feb 2013 11:50:37 -0500 |
Ken Hornstein <address@hidden> writes:
> So since the prototype for functions like strcpy() and the like are "char",
> in theory this would suppress the warnings. But still ... I understand
> David's reasons for wanting to use unsigned char (it feels more correct
> to me as well), but I hate the idea of relying on specific C compiler
> options. For better or worse the POSIX API has pretty much mandated
> that C character strings are "char", and casting the arguments to the
> ctype macros seems to be the way the world deals with that.
FWIW, strings as "char *" and then explicitly casting all ctype.h macro
arguments to "unsigned char" is the solution the postgresql project has
been using for quite some time, so I'm familiar with it. It works; the
main downside is that if you forget the "(unsigned char)" someplace,
you won't get any warning that the usage is unportable, and most likely
you won't notice the mistake in testing either.
I have one machine on which I've hacked things up so that I do get a
warning from such constructs --- what you need is for the ctype macros
to expand to array references, and then make sure gcc's warn-for-char-
used-as-subscript option is on.
regards, tom lane
- Re: [Nmh-workers] Compiler warnings and signed vs. unsigned char, again, David Levine, 2013/02/04
- Re: [Nmh-workers] Compiler warnings and signed vs. unsigned char, again, Ken Hornstein, 2013/02/04
- Re: [Nmh-workers] Compiler warnings and signed vs. unsigned char, again, Ralph Corderoy, 2013/02/05
- Re: [Nmh-workers] Compiler warnings and signed vs. unsigned char, again, Ken Hornstein, 2013/02/05
- Re: [Nmh-workers] Compiler warnings and signed vs. unsigned char, again, Ralph Corderoy, 2013/02/05
- Re: [Nmh-workers] Compiler warnings and signed vs. unsigned char, again, Ken Hornstein, 2013/02/05
- Re: [Nmh-workers] Compiler warnings and signed vs. unsigned char, again, Lyndon Nerenberg, 2013/02/05
- Re: [Nmh-workers] Compiler warnings and signed vs. unsigned char, again, Ken Hornstein, 2013/02/05
- Re: [Nmh-workers] Compiler warnings and signed vs. unsigned char, again,
Tom Lane <=
- Re: [Nmh-workers] Compiler warnings and signed vs. unsigned char, again, Lyndon Nerenberg, 2013/02/05