Re: signed | unsigned char?

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

 



On Thu, Sep 12, 2013 at 12:46 PM, ballsystemlord <doark@xxxxxxxx> wrote:
> I'm wondering what type of char I should pass to the various functions that
> deal with strings. I also wanted to know if it mattered.

You should normally pass the type 'char'.  When dealing only when
strings it rarely matters.

> I was just passing char to functions but I wanted to know how big it was and
> that's not easy to find out when you don't know if it's signed or not.

By definition sizeof(char) == 1.  You can find the minimum and maximum
valuesof char by #include <limits.h> and looking at CHAR_MIN and
CHAR_MAX.

> I tried using unsigned chars and char and then compiling with the option
> -unsigned-char (I think it's called) but I'm still getting warnings like:
>
> -wsign-compare
> XXXXXXX function expected `char' but argument is type `unsigned char'

That is as expected.

By the way, these questions are more related to C in general than to
GCC in particular.

Ian




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux