C
Charles Sullivan
I have a program written in C under Linux (gcc) which a user has
ported to run under AT&T SysV R4.
He sent me a copy of his makelog which displays a large number
of compiler warnings similar to this:
warning: semantics of ">>" change in ANSI C; use explicit cast
The statement to which this applies is:
xuc = ((uc[7] & 0xF0 ) >> 4);
where the declarations for xuc and uc are:
extern unsigned char xuc;
unsigned char uc[20];
I assume this warning means his compiler expects the number
4 in that statement to be cast as an unsigned char, but I
haven't yet found a warning level switch in my gcc compiler
which displays this warning, so can't be sure. There's no
such warning for another statement in the same function:
xi = uc[8] + (uc[9] << 8);
where in this case:
extern int xi;
Is his compiler being overly picky or is the (apparently
expected) cast something that should be done in well-written
C code?
(Note: the variable names shown are simplified for clarity;
the actual names used are much more self-explanatory).
Thanks for your help.
Regards,
Charles Sullivan
ported to run under AT&T SysV R4.
He sent me a copy of his makelog which displays a large number
of compiler warnings similar to this:
warning: semantics of ">>" change in ANSI C; use explicit cast
The statement to which this applies is:
xuc = ((uc[7] & 0xF0 ) >> 4);
where the declarations for xuc and uc are:
extern unsigned char xuc;
unsigned char uc[20];
I assume this warning means his compiler expects the number
4 in that statement to be cast as an unsigned char, but I
haven't yet found a warning level switch in my gcc compiler
which displays this warning, so can't be sure. There's no
such warning for another statement in the same function:
xi = uc[8] + (uc[9] << 8);
where in this case:
extern int xi;
Is his compiler being overly picky or is the (apparently
expected) cast something that should be done in well-written
C code?
(Note: the variable names shown are simplified for clarity;
the actual names used are much more self-explanatory).
Thanks for your help.
Regards,
Charles Sullivan