Mailing List Archive
tlug.jp Mailing List tlug archive tlug Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]Re: [tlug] compilation warnings for unsigned char
- Date: Wed, 5 Jul 2006 21:52:09 -0400
- From: Jim <jep200404@example.com>
- Subject: Re: [tlug] compilation warnings for unsigned char
- References: <200607060115.k661F4nV003268@example.com>
Jim Breen wrote: > ... I'd like to tidy up a squillion compilation warnings ... > xjdic handles all its text in unsigned char strings. > With my latest distro (FDC4) the gcc (version 4.0.2 20051125 (Red Hat > 4.0.2-8)) spews out warnings for every strcpy, strcat, etc. E.g. > > xjdserver.c:228: warning: pointer targets in passing argument 1 of > 'strcpy' differ in signedness > xjdserver.c:228: warning: pointer targets in passing argument 2 of > 'strcpy' differ in signedness > Now in that case, both arguments are "unsigned char", so I assume > the warning is because strcpy's prototype says it should be "char". Yup. That's makes sense to me also. > Can anyone suggest a solution/workaround? Where: unsigned char foo1; unsigned char foo2; Instead of: strcpy(foo1,foo2); try: strcpy((char)foo1,(char)foo2); or even: strcpy((signed char)foo1,(signed char)foo2); Another _completely_ disgusting hack would be: unsigned char usfoo1; unsigned char usfoo2; #define foo1 ((signed char)usfoo1) #define foo2 ((signed char)usfoo2) strcpy(foo1,foo2); which would allow you to leave the arguments unmolested, but #defined foo1 and foo2 probably would not fly as lvalues. Yet another disgusting hack would be unions. Something like: typedef union { unsigned char uc; signed char sc; } euchre; euchre usfoo1; euchre usfoo2; #define foo1 (usfoo1.sc) #define foo2 (usfoo2.sc) strcpy(foo1,foo2); So there are three bottles, all of which are filled with iocaine. Choose your poison.
- References:
- [tlug] compilation warnings for unsigned char
- From: Jim Breen
Home | Main Index | Thread Index
- Prev by Date: [tlug] compilation warnings for unsigned char
- Next by Date: Re: [tlug] Baby Steps for Command Line Backups . . . . . . . . . . . . . . .
- Previous by thread: [tlug] compilation warnings for unsigned char
- Next by thread: Re: [tlug] compilation warnings for unsigned char
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links