EmbeddedRelated.com
Forums

IAR + signed char

Started by lukasz_krysiewicz January 18, 2009
Hi for all.

I have "problem" with signed char.

For example I have empty C project, and in IAR opions (Opions -> C/C++ Compiller) I change default type char. Default is unsigned, but I want have signed default char format.

When I choose correct checkbox (signed), and meked project, then I have many warnings (more than 600).

I think that in IAR lib's somebody use char and char is default unsigned. Have I right. And what I can do in this situation ?

Bye
----------------------------------
Speak Up. Angielski szybko i skutecznie. 3 miesiace nauki gratis.
Sprawdz. >> http://link.interia.pl/f2019

Beginning Microcontrollers with the MSP430

The range of a char is chosen by the implementer, the range is in the limits.h header..
if you need the default to be different and to be compatible with the libraries when you change the defaut then you need to recompile the libraries for the different char range.. usually the programs will work fine (as long as you really dont need the negative range) without recompiling but you get warnings (not errors).. You will see alot when passing text strings to functions..

Crosworks and IAR use a char as unsigned
Quadravox uses it as signed, not sure about GCC or CCE.

If you are concerned with portabiliy, you are better using typdef to create a specific type like uint8 or int8..

--- On Sun, 1/18/09, lukasz_krysiewicz wrote:

> From: lukasz_krysiewicz
> Subject: [msp430] IAR + signed char
> To: m...
> Date: Sunday, January 18, 2009, 9:26 AM
> Hi for all.
>
> I have "problem" with signed char.
>
> For example I have empty C project, and in IAR opions
> (Opions -> C/C++ Compiller) I change default type char.
> Default is unsigned, but I want have signed default char
> format.
>
> When I choose correct checkbox (signed), and meked project,
> then I have many warnings (more than 600).
>
> I think that in IAR lib's somebody use char and char is
> default unsigned. Have I right. And what I can do in this
> situation ?
>
> Bye
> ----------------------------------
> Speak Up. Angielski szybko i skutecznie. 3 miesiace nauki
> gratis.
> Sprawdz. >> http://link.interia.pl/f2019
>
Thanks a lot for response.

In my commercial projects I use typedefs, but I want know true about signed char.

One more time thanks.

The range of a char is chosen by the implementer, the range is in the limits.h header..
if you need the default to be different and to be compatible with the libraries when you change the defaut then you need to recompile the libraries for the different char range.. usually the programs will work fine (as long as you really dont need the negative range) without recompiling but you get warnings (not errors).. You will see alot when passing text strings to functions..

Crosworks and IAR use a char as unsigned
Quadravox uses it as signed, not sure about GCC or CCE.

If you are concerned with portabiliy, you are better using typdef to create a specific type like uint8 or int8..

-----------------------------------
Promocja w Speak Up. Kwartal angielskiego za darmo.
3 miesiace nauki gratis. Sprawdz teraz! >> http://link.interia.pl/f2019
lukasz_krysiewicz wrote:
> Hi for all.
>
> I have "problem" with signed char.
>
> For example I have empty C project, and in IAR opions (Opions -> C/C++ Compiller) I change default type char. Default is unsigned, but I want have signed default char format.
>
> When I choose correct checkbox (signed), and meked project, then I have many warnings (more than 600).
>
> I think that in IAR lib's somebody use char and char is default unsigned. Have I right. And what I can do in this situation ?

Hi Lukasz!

The run-time library is built and tested using "char" as an unsigend
type. The compiler option is provided mainly for extreme cases, where it
would be impossible to have "char" as unsigned.

I would strongly recommend against using the option, if you do you can
choose between the following two ways, neither of which is comfortable:

* Live with the warnings. The drawback is that this might hide real
warnings.

* Rebuilding the run-time library with this option set. Since this is
not something we do routinely, you have to ensure that all routines you
use work as expected.

I would recommend that you write your application so that it is not
dependent on the signedness of "char", i.e. explicitly use "signed char"
or "unsigned char" whenever the signedness matter.

-- Anders Lindgren, IAR Systems
--
Disclaimer: Opinions expressed in this posting are strictly my own and
not necessarily those of my employer.