avr-gcc-list
[Top][All Lists]
Advanced

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

Re: [avr-gcc-list] are signed chars signed :-) ?


From: Uwe Arends
Subject: Re: [avr-gcc-list] are signed chars signed :-) ?
Date: Tue, 7 Sep 2004 09:11:34 +0200

> > > I just understood that 2 minutes ago by looking at the avr-libc source!
> > > First time that I encounter such an environment! I have to go thru all my
> > > code to modify 'char' to 'signed char'.
> >
> > you probably know about the -fsigned-char commandline switch, don't you?!?!?
> >
> 
> The "-fsigned-char" flag would definitely save him some effort, but it is

That was the intention, to save him some work.
 
> still best to be explicit in the code.  Writing code whose correctness
> depends on compiler flags is a bad idea.

yup

> As a rule, plain "char" should only be used when you really mean a
> character - i.e., a letter in a string.  "unsigned char" and "signed char"
> are silly names - what sense is there in talking about a negative letter?
> The best way (in that it makes your code more readable, and removes a source
> of error) is to use typedefs to give sensible names to "unsigned char" and
> "signed char", which you then use consistently.  A prime example would be to
> simply include the <inttypes.h> from avr-libc, and use int8_t and uint8_t.

I wholeheartedly agree :-)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]