This is the mail archive of the
xconq7@sources.redhat.com
mailing list for the Xconq project.
Re: Compile Warnings
- From: Eric McDonald <mcdonald at phy dot cmich dot edu>
- To: Hans Ronne <hronne at comhem dot se>
- Cc: Jim Kingdon <kingdon at panix dot com>, <xconq7 at sources dot redhat dot com>
- Date: Mon, 10 May 2004 19:04:11 -0400 (EDT)
- Subject: Re: Compile Warnings
On Tue, 11 May 2004, Hans Ronne wrote:
> >Well, the code really is bogus. It should be saying "unsigned char"
> >but instead says "char". In practice it should be relatively
> >portable, although I don't know about its legality in a language
> >lawyer sense.
>
> In fact, those unsigned chars were added two years ago, as part of the C++
> compatibility patches:
You mean changed from 'unsigned char' to 'char'.
We can humor both pedantic ANSI C and C++ by doing something like
the following:
#ifdef __cplusplus
#define BMAP_BYTE char
#else
#define BMAP_BYTE unsigned char
#endif
and then use BMAP_BYTE for the type.
It turns out that Xlib will take either char or unsigned char
arrays for this function, XCreateBitmapFromData or whatever, if my
research last night is correct.
So, this must mean that C does an automatic widening conversion
from char to unsigned char. I will double-check my ANSI C
reference from K&R to verify this. Considering how long I have
been doing C programming, it is amazing that I have to look up
such a piece of trivia.
> Now, if the choice is between ANSI pedantic code and C++ compatibility, I
> would probably opt for the latter.
I would opt for both. :-)
Eric