Re: Some architectures need "signed char" declarations

From: Doug Royer <Doug(at)royer(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Some architectures need "signed char" declarations
Date: 2002-01-09 17:37:38
Message-ID: 3C3C7FE2.B7F45E56@Royer.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane wrote:
>
> Doug McNaught <doug(at)wireboard(dot)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 Content-Type Size
Doug.vcf text/x-vcard 363 bytes

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2002-01-09 17:58:45 Does getopt() return "-1", or "EOF", at end?
Previous Message Bruce Momjian 2002-01-09 17:19:11 Re: [HACKERS] --with-tcl build on AIX (and others) fails