[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: wmappl



On Wed, 2002-07-10 at 23:09, Mij wrote:
> Aaron Schrab wrote:
> 
> >At 14:59 +0200 10 Jul 2002, Mij <mijio@mac.com> wrote
> >
> >
> >It's storing the return value from fgetc() into a char variable.  This
> >is wrong, fgetc() is documented as returning an int (it needs to be able
> >to return any valid char or EOF, so a char isn't big enough).
> >
> >  
> >
> 
> That's right, but as Theo noted, expliciting the char "signed" clears 
> the problem.
> That's really strange. I think this depends on two's complement notation 
> AND endianess,
> but I'm really curious to know something more.
> "Signed" is an implicit keyword, and it doesn't implies any specific 
> behaviour. It's simply
> implied. Then, I think the problem comes from a gcc optimization.
> 
> When i'll have 1 minute, i'm going to go deep in this problem.

No need to go deep into the problem. You can never assume that char can
hold an int on every platform, and on PPC, it doesn't. Char on PPC is
unsigned.

Solution 1) use -signed-char in the CFLAGS (I never actually used that,
this is probably not compatible with all the compilers on the planet)
2) replace char by signed char in the source
3) replace char by int in the source.

Cheers

-- 
/Bastien Nocera
http://hadess.net

Attachment: signature.asc
Description: This is a digitally signed message part


Reply to: