这是我的第一个 SO 问题,所以请保持温和。:)
我不是编程专家。我有一个正在玩的程序。它带有一些 BMP 文件。我仍然有 BMP 文件,但我正在将它们转换为 C 代码。目前,我正在加载它们:
static char bits[] = {
0xff,0xff,0xff,0xff,0xff,0xab,0xaa,0x5a,0x55,0xd5,0x55,0x55,0xb5,0xaa,0xaa,
0xab,0xaa,0x5a,0x55,0xd5,0x55,0x55,0xb5,0xaa,0xaa,0xab,0xaa,0x5a,0x55,0xd5,
[blah blah blah]
0xff,0xff,0xff,0xff,0xff};
walls.pixmap = XCreateBitmapFromData(dpy,DefaultRootWindow(dpy),bits,40,40);
每个大于 0x80 的字符都会生成此警告:
bitmaps.c:38: warning: overflow in implicit constant conversion
所以我尝试将我的定义更改为
static unsigned char bits[] = {
但这会显示一个新警告:
bitmaps.c:31: warning: pointer targets in passing argument 3 of 'XCreateBitmapFromData' differ in signedness
/usr/include/X11/Xlib.h:1607: note: expected 'const char *' but argument is of type 'unsigned char *'
有没有办法加载将编译而没有警告的位图?我应该接受总是会出现警告吗?既然我有原始 BMP 文件,我应该做一些不同的事情吗?
谢谢。