Re: signedness of wireless keys.
- From: Peter Jones <pjones redhat com>
- To: Robert Love <rml novell com>
- Cc: rml ximian com, NetworkManager-list gnome org
- Subject: Re: signedness of wireless keys.
- Date: Mon, 12 Dec 2005 14:17:39 -0500
On Mon, 2005-12-12 at 13:49 -0500, Robert Love wrote:
> On Mon, 2005-12-12 at 13:48 -0500, Dan Williams wrote:
>
> > Sounds good to me unless there are other objections. What kind of
> > annoys me though is that when doing strlen(), strcmp() and whatnot, all
> > the standard library calls take signed char, which means a boatload of
> > casting.
>
> Yup.
Actually, I'm wrong about what we should use, and this analysis is also
wrong.
In C, "char" is not the same thing as either "signed char" or "unsigned
char".
If an object is defined as "char", it is guaranteed to be positive when
storing a member of the basic execution character set (i.e. ascii for
us), and the sign when using any other values is implementation defined.
In gcc, the sign is setable with -funsigned-char or -fsigned-char. But
neither of these actually makes it the same type as "signed char" (which
is on the list of signed types next to "short int", "int", etc) or
"unsigned char". It only changes the behavior, not what type it is.
In linux with gcc we'll always get 8-bits, and we don't really (or at
least shouldn't) care which sign it is, so we should always use "char
*", and let the compiler figure out which sign is which.
--
Peter
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]