Re: Some architectures need "signed char" declarations - Mailing list pgsql-hackers

From Doug Royer
Subject Re: Some architectures need "signed char" declarations
Date
Msg-id 3C3C7FE2.B7F45E56@Royer.com
Whole thread Raw
In response to Some architectures need "signed char" declarations  (Oliver Elphick <olly@lfix.co.uk>)
Responses Re: Some architectures need "signed char" declarations  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Tom Lane wrote:
>
> Doug McNaught <doug@wireboard.com> writes:
> > Hmmm, according to my knowledge of C, 'c' should be an int here, as
> > EOF is guaranteed not to collide with any legal char value.
>
> I agree with Doug: EOF is not supposed to be equal to any value of
> 'char', therefore changing the variables to signed char will merely
> break something else.  Probably the variables should be int; are their
> values coming from getc() or some such?  Will look at it.

I deleted the original post, but I think the issue was signed
versus unsigned comparisons. I think he was saying the
variable should be explicitly declared as 'signed int'
(or signed char) and not 'int' (or char) because EOF is (-1).

    unsigned int foo;

    if (foo == -1) ...    causes a warning (or errors)
                on many compilers.

And if the default for int or char is unsigned as it can
be on some systems, the code does exactly that.

Perhaps he is just wanted to reduce the build time noise?

Apologies if this was not on point.
Attachment

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: --with-tcl build on AIX (and others) fails
Next
From: Tom Lane
Date:
Subject: Does getopt() return "-1", or "EOF", at end?