c++ - compiling wxWidgets with c++0x flags -
while trying compile wxwidgets-2.9.1
source c++0x
flags using gcc-4.6
. came across error
narrowing conversion of '128' 'int' 'char' inside { } [-fpermissive]
in file src/gtk/dcclient.cpp
. error comes following files:
- src/gtk/bdiag.xbm
- src/gtk/cdiag.xbm
- src/gtk/fdiag.xbm
- src/gtk/horiz.xbm
- src/gtk/verti.xbm
- src/gtk/cross.xbm
this known bug. http://trac.wxwidgets.org/ticket/12575 did required , program compiling okay.
basically, there 2 kinds of fix diff
file has
//in file dcclient.h
hatches[i] = gdk_bitmap_create_from_data(null, bdiag_bits, bdiag_width, bdiag_height); hatches[i] = gdk_bitmap_create_from_data(null, reinterpret_cast< const char* >(bdiag_bits), bdiag_width, bdiag_height);
//in file bdiag.xbm , similar fixes in *.xbm files
static char bdiag_bits[] = {
static unsigned char bdiag_bits[] = { 0x80, 0x80, 0x40, 0x40, 0x20, 0x20, 0x10, 0x10, 0x08, 0x08, 0x04, 0x04, 0x02, 0x02, 0x01, 0x01, 0x80, 0x80, 0x40, 0x40, 0x20, 0x20, 0x10, 0x10, 0x08, 0x08, 0x04, 0x04, 0x02, 0x02, 0x01, 0x01};
i understand second fix
not understand first one. why need reinterpret_cast< const char* >
function gdk_bitmap_create_from_data
declared this:
typedef char gchar;//in other header file
gdkbitmap* gdk_bitmap_create_from_data (gdkdrawable *drawable, const gchar *data, gint width, gint height);
while few lines later in same file dcclient.cpp following call gdk_bitmap_create_from_data
doesn't give error.
char* data = new char[data_size]; //... gdkpixmap* pixmap = gdk_bitmap_create_from_data(mask, data, dst_w, dst_h);
now here no typecast required. why need reinterpret_cast on static unsigned char*
?
unsigned char
, signed char
, char
(also known 'plain char') 3 different types. there no conversion between unsigned char*
, char*
.
Comments
Post a Comment