
Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [tlug] compilation warnings for unsigned char
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.
Home |
Main Index |
Thread Index