I really don't like to ignore the warning message from compiler. so I am spending some effort (R2) on subject of gcc compilation warning message. Hope to get rid all of them. Fist challenge is "unsigned char" usage, The question is why Henrik decided to use "unsigned char" on strings,array in hobbit source code ? According R1 book, unsigned character is 1 byte long and value range to be 0 to 2^8 -1. signed character is 1 byte long and value range is -2^7 to 2^7-1. both signed and unsigned char are all 1 byte long, so saving space is not a motive. Is the intention of declaring unsigned char is to disallow minus value(non-ASCII) in a character ? R1: C a software engineering approach by Peter A. Darneil. R2: http://en.wikibooks.org/wiki/System_Monitoring_with_Xymon/Developer_Guide#Co... R3: following two example diffs are illustration of places in src using unsigned char. <snip> Index: client/clientupdate.c =================================================================== --- client/clientupdate.c (revision 6219) +++ client/clientupdate.c (working copy) @@ -96,7 +96,7 @@ char tmpfn[PATH_MAX]; char *srcfn; FILE *tmpfd, *srcfd; - unsigned char buf[8192]; + char buf[8192]; long n; struct stat st; int cperr; Index: client/logfetch.c =================================================================== --- client/logfetch.c (revision 6219) +++ client/logfetch.c (working copy) @@ -431,7 +431,7 @@ static char *result = NULL; digestctx_t *ctx; FILE *fd; - unsigned char buf[8192]; + char buf[8192]; int openerr, buflen; if ((ctx = digest_init(dtype)) == NULL) return ""; [tjyang at f12 4.3.0]$ On Wed, Feb 17, 2010 at 11:45 AM, Malcolm Hunter <malcolm.hunter at gmx.co.uk> wrote:
Why is there something like this:
unsigned char *message;
or static unsigned char *cause = NULL;
I am guessing these are strings - so why the unsigned?
This thread may help explain:
http://bytes.com/topic/c/answers/61480-why-use-unsigned-char-ever
Malcolm
-- Technical copy-editor & proofreader
KDE Proofreading Team KDE British English Translation Team
http://l10n.kde.org/team-infos.php?teamcode=en_GB
Facebook: http://www.facebook.com/FriendlyAtheist
NEU: Mit GMX DSL über 1000,- ¿ sparen! http://portal.gmx.net/de/go/dsl02
To unsubscribe from the hobbit list, send an e-mail to hobbit-unsubscribe at hswn.dk
-- T.J. Yang