[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 03:04:47PM +0200, Reinier Post wrote:
> 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
I'm not sure. I have only remembered that this was a well discussed
topic.
> | [-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:
>
> | 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.
So the macros work for the value set [-1,255]. The int type (or short
int) is the smallest type which holds this range. It is ok to feed a
{,unsigned,signed} char to this macro. The problem is about the
implementation of the macros.
> 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.
I would vote for the wrappers.
Raimar
--
email: rf13@xxxxxxxxxxxxxxxxx
"This is Linux Country. On a quiet night, you can hear Windows reboot."
|
|