[Freeciv-Dev] Re: gcc warnings on solaris
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
On Tue, Sep 11, 2001 at 11:44:35AM +0200, Raimar Falke wrote:
> On Mon, Sep 10, 2001 at 04:33:53PM -0700, Paul Zastoupil wrote:
> > gcc on solaris gives warnings for calling functions with the wrong types.
> > Like:
> > warning: subscript has type `char'
> >
> > All of the warnings were for functions like isspace and friends which
> > take int.
> >
> > So, if any one cares, attached is a patch.
>
> Please read the old thread:
> <http://arch.freeciv.org/freeciv-dev-200101/threads.html#00543>
>
> Raimar
I'm not sure what you want Paul to conclude from that thread. In
http://arch.freeciv.org/freeciv-dev-200101/msg00578.html
you wrote:
| So isalnum() is a macro which uses arrays and the compiler gives
| warnings. Quoting from glibc's ctype.h:
| These point into arrays of 384, so they can be indexed by any `unsigned
| char' value [0,255]; by EOF (-1); or by any `signed char' value
| [-128,-1). ISO C requires that the ctype functions work for `unsigned
| char' values and for EOF; we also support negative `signed char' values
| for broken old programs. The case conversion arrays are of `int's
| rather than `unsigned char's because tolower (EOF) must be EOF, which
|
| So isalnum() works only for unsigned char on all platforms.
But isalnum() still wants an int on Solaris. The manpage says:
| C Library Functions ctype(3C)
|
|
|
| NAME
| ctype, isdigit, isxdigit, islower, isupper, isalpha, isal-
| num, isspace, iscntrl, ispunct, isprint, isgraph, isascii -
| character handling
|
| SYNOPSIS
| #include <ctype.h>
|
| int isalpha(int c);
[...]
| DESCRIPTION
| These macros classify character-coded integer values. Each
| is a predicate returning non-zero for true, 0 for false. The
| behavior of these macros, except isascii(), is affected by
| the current locale (see setlocale(3C)). To modify the
| behavior, change the LC_TYPE category in setlocale(), that
| is, setlocale(LC_CTYPE, newlocale). In the "C" locale, or in
| a locale where character type information is not defined,
| characters are classified according to the rules of the US-
| ASCII 7-bit coded character set.
|
| The macro isascii() is defined on all integer values; the
| rest are defined only where the argument is an int, the
| value of which is representable as an unsigned char, or EOF,
| which is defined by the <stdio.h> header and represents
| end-of-file.
[...]
The manpage doesn't actually say that it's safe to cast unsigned
chars to int at least for the C locale, but that seems to be the
proper way to handle it, unless you want to introduce another set
of fc_ wrappers.
--
Reinier Post
|
|