From 903506828b7d042350eae97b5014a63ffca17ef5 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 9 Jan 2002 12:49:12 +0000 Subject: [PATCH] fixes for the compilation warnings with Sun CC: 1. some fixes for "String literal to char * conversion" warnings (many more left in the *.xpm files) 2. fixes for "assignment of function to extern "C" function" 3. a few other miscellaneous ones git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13478 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/db.h | 6 ++- include/wx/defs.h | 11 ++-- include/wx/dynarray.h | 3 ++ include/wx/geometry.h | 20 +++---- include/wx/html/htmltag.h | 2 +- include/wx/list.h | 3 ++ src/common/cshelp.cpp | 2 +- src/common/db.cpp | 6 ++- src/common/encconv.cpp | 2 +- src/common/imagjpeg.cpp | 55 +++++++++++--------- src/common/imagpng.cpp | 9 +++- src/common/imagtiff.cpp | 23 ++++---- src/common/list.cpp | 2 +- src/common/resource.cpp | 2 +- src/common/socket.cpp | 7 +-- src/common/string.cpp | 3 +- src/common/wxexpr.cpp | 2 +- src/common/xpmdecod.cpp | 2 +- src/generic/dirctrlg.cpp | 16 +++--- src/generic/listctrl.cpp | 3 +- src/gtk/app.cpp | 107 +++++++++++++++++++++----------------- src/gtk/dnd.cpp | 2 +- src/gtk/menu.cpp | 23 ++++---- src/gtk/minifram.cpp | 10 +++- src/gtk/timer.cpp | 2 +- src/gtk/toplevel.cpp | 18 +++++-- src/gtk/utilsgtk.cpp | 5 +- src/gtk/win_gtk.c | 2 +- src/gtk/window.cpp | 29 ++++++++--- src/gtk1/app.cpp | 107 +++++++++++++++++++++----------------- src/gtk1/dnd.cpp | 2 +- src/gtk1/menu.cpp | 23 ++++---- src/gtk1/minifram.cpp | 10 +++- src/gtk1/timer.cpp | 2 +- src/gtk1/toplevel.cpp | 18 +++++-- src/gtk1/utilsgtk.cpp | 5 +- src/gtk1/win_gtk.c | 2 +- src/gtk1/window.cpp | 29 ++++++++--- src/html/helpdata.cpp | 5 +- src/html/htmlpars.cpp | 4 +- src/html/htmltag.cpp | 4 +- src/unix/threadpsx.cpp | 30 +++++++---- src/unix/utilsunx.cpp | 2 +- 43 files changed, 380 insertions(+), 240 deletions(-) diff --git a/include/wx/db.h b/include/wx/db.h index cc2c1d84e8..1de7c38f10 100644 --- a/include/wx/db.h +++ b/include/wx/db.h @@ -706,8 +706,10 @@ int WXDLLEXPORT wxDbConnectionsInUse(void); // Writes a message to the wxLog window (stdout usually) when an internal error // situation occurs. This function only works in DEBUG builds -const wxChar WXDLLEXPORT *wxDbLogExtendedErrorMsg(const wxChar *userText, wxDb *pDb, - wxChar *ErrFile, int ErrLine); +const wxChar WXDLLEXPORT *wxDbLogExtendedErrorMsg(const wxChar *userText, + wxDb *pDb, + const wxChar *ErrFile, + int ErrLine); // This function sets the sql log state for all open wxDb objects diff --git a/include/wx/defs.h b/include/wx/defs.h index 9b52f03dc5..5ea5a2b782 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -235,16 +235,19 @@ typedef int wxWindowID; #define wxCALLBACK #endif // platform -// callling convention for the qsort(3) callback +// generic calling convention for the extern "C" functions #if defined(__VISUALC__) - #define wxCMPFUNC_CONV _cdecl + #define wxC_CALLING_CONV _cdecl #elif defined(__VISAGECPP__) - #define wxCMPFUNC_CONV _Optlink + #define wxC_CALLING_CONV _Optlink #else // !Visual C++ - #define wxCMPFUNC_CONV + #define wxC_CALLING_CONV #endif // compiler +// callling convention for the qsort(3) callback +#define wxCMPFUNC_CONV wxC_CALLING_CONV + // compatibility :-( #define CMPFUNC_CONV wxCMPFUNC_CONV diff --git a/include/wx/dynarray.h b/include/wx/dynarray.h index 9a00c3a7bd..e010339d8b 100644 --- a/include/wx/dynarray.h +++ b/include/wx/dynarray.h @@ -42,7 +42,10 @@ callback compare function for quick sort must return negative value, 0 or positive value if pItem1 <, = or > pItem2 */ +extern "C" +{ typedef int (wxCMPFUNC_CONV *CMPFUNC)(const void* pItem1, const void* pItem2); +} // ---------------------------------------------------------------------------- /** diff --git a/include/wx/geometry.h b/include/wx/geometry.h index d8d0a8a226..5d91ae5ed2 100644 --- a/include/wx/geometry.h +++ b/include/wx/geometry.h @@ -97,16 +97,16 @@ public : wxDouble m_y; }; -wxPoint2DDouble operator+(const wxPoint2DDouble& pt1 , const wxPoint2DDouble& pt2); -wxPoint2DDouble operator-(const wxPoint2DDouble& pt1 , const wxPoint2DDouble& pt2); -wxPoint2DDouble operator*(const wxPoint2DDouble& pt1 , const wxPoint2DDouble& pt2); -wxPoint2DDouble operator*(wxDouble n , const wxPoint2DDouble& pt); -wxPoint2DDouble operator*(wxInt32 n , const wxPoint2DDouble& pt); -wxPoint2DDouble operator*(const wxPoint2DDouble& pt , wxDouble n); -wxPoint2DDouble operator*(const wxPoint2DDouble& pt , wxInt32 n); -wxPoint2DDouble operator/(const wxPoint2DDouble& pt1 , const wxPoint2DDouble& pt2); -wxPoint2DDouble operator/(const wxPoint2DDouble& pt , wxDouble n); -wxPoint2DDouble operator/(const wxPoint2DDouble& pt , wxInt32 n); +inline wxPoint2DDouble operator+(const wxPoint2DDouble& pt1 , const wxPoint2DDouble& pt2); +inline wxPoint2DDouble operator-(const wxPoint2DDouble& pt1 , const wxPoint2DDouble& pt2); +inline wxPoint2DDouble operator*(const wxPoint2DDouble& pt1 , const wxPoint2DDouble& pt2); +inline wxPoint2DDouble operator*(wxDouble n , const wxPoint2DDouble& pt); +inline wxPoint2DDouble operator*(wxInt32 n , const wxPoint2DDouble& pt); +inline wxPoint2DDouble operator*(const wxPoint2DDouble& pt , wxDouble n); +inline wxPoint2DDouble operator*(const wxPoint2DDouble& pt , wxInt32 n); +inline wxPoint2DDouble operator/(const wxPoint2DDouble& pt1 , const wxPoint2DDouble& pt2); +inline wxPoint2DDouble operator/(const wxPoint2DDouble& pt , wxDouble n); +inline wxPoint2DDouble operator/(const wxPoint2DDouble& pt , wxInt32 n); inline wxPoint2DDouble::wxPoint2DDouble() { diff --git a/include/wx/html/htmltag.h b/include/wx/html/htmltag.h index 981f2374e5..758e1d3a0e 100644 --- a/include/wx/html/htmltag.h +++ b/include/wx/html/htmltag.h @@ -107,7 +107,7 @@ public: // (like sscanf() does) // NOTE: unlike scanf family, this function only accepts // *one* parameter ! - int ScanParam(const wxString& par, wxChar *format, void *param) const; + int ScanParam(const wxString& par, const wxChar *format, void *param) const; // Returns string containing all params. wxString GetAllParams() const; diff --git a/include/wx/list.h b/include/wx/list.h index 477e4fc48d..cfccbf371d 100644 --- a/include/wx/list.h +++ b/include/wx/list.h @@ -64,7 +64,10 @@ enum wxKeyType // type of compare function for list sort operation (as in 'qsort'): it should // return a negative value, 0 or positive value if the first element is less // than, equal or greater than the second +extern "C" +{ typedef int (* LINKAGEMODE wxSortCompareFunction)(const void *elem1, const void *elem2); +} // typedef int (* LINKAGEMODE wxListIterateFunction)(void *current); diff --git a/src/common/cshelp.cpp b/src/common/cshelp.cpp index ba35623830..e2737d2ed1 100644 --- a/src/common/cshelp.cpp +++ b/src/common/cshelp.cpp @@ -218,7 +218,7 @@ bool wxContextHelp::DispatchEvent(wxWindow* win, const wxPoint& pt) */ #if !defined(__WXMSW__) -static char * csquery_xpm[] = { +static const char * csquery_xpm[] = { "12 11 2 1", " c None", ". c #000000", diff --git a/src/common/db.cpp b/src/common/db.cpp index f32276faf0..065a0ac9d5 100644 --- a/src/common/db.cpp +++ b/src/common/db.cpp @@ -3721,8 +3721,10 @@ int WXDLLEXPORT wxDbConnectionsInUse(void) /********** wxDbLogExtendedErrorMsg() **********/ // DEBUG ONLY function -const wxChar WXDLLEXPORT *wxDbLogExtendedErrorMsg(const wxChar *userText, wxDb *pDb, - wxChar *ErrFile, int ErrLine) +const wxChar WXDLLEXPORT *wxDbLogExtendedErrorMsg(const wxChar *userText, + wxDb *pDb, + const wxChar *ErrFile, + int ErrLine) { static wxString msg; msg = userText; diff --git a/src/common/encconv.cpp b/src/common/encconv.cpp index a266d02c91..8422433e81 100644 --- a/src/common/encconv.cpp +++ b/src/common/encconv.cpp @@ -54,7 +54,7 @@ typedef struct { -static int LINKAGEMODE CompareCharsetItems(const void *i1, const void *i2) +extern "C" int LINKAGEMODE CompareCharsetItems(const void *i1, const void *i2) { return ( ((CharsetItem*)i1) -> u - ((CharsetItem*)i2) -> u ); } diff --git a/src/common/imagjpeg.cpp b/src/common/imagjpeg.cpp index 2f5cd0a432..d16360ce17 100644 --- a/src/common/imagjpeg.cpp +++ b/src/common/imagjpeg.cpp @@ -58,6 +58,11 @@ extern "C" #endif #endif +// we can't use METHODDEF here as it includes static yet the functions must be +// extern "C" and these can't be used together! +#undef METHODDEF +#define METHODDEF(type) extern "C" wxC_CALLING_CONV type + //----------------------------------------------------------------------------- // wxJPEGHandler //----------------------------------------------------------------------------- @@ -125,29 +130,6 @@ METHODDEF(void) my_term_source ( j_decompress_ptr cinfo ) delete[] src->buffer; } -void jpeg_wxio_src( j_decompress_ptr cinfo, wxInputStream& infile ) -{ - my_src_ptr src; - - if (cinfo->src == NULL) { /* first time for this JPEG object? */ - cinfo->src = (struct jpeg_source_mgr *) - (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, - sizeof(my_source_mgr)); - src = (my_src_ptr) cinfo->src; - } - src = (my_src_ptr) cinfo->src; - src->pub.bytes_in_buffer = 0; /* forces fill_input_buffer on first read */ - src->buffer = new JOCTET[JPEG_IO_BUFFER_SIZE]; - src->pub.next_input_byte = NULL; /* until buffer loaded */ - src->stream = &infile; - - src->pub.init_source = my_init_source; - src->pub.fill_input_buffer = my_fill_input_buffer; - src->pub.skip_input_data = my_skip_input_data; - src->pub.resync_to_restart = jpeg_resync_to_restart; /* use default method */ - src->pub.term_source = my_term_source; -} - // JPEG error manager: @@ -163,8 +145,7 @@ typedef struct my_error_mgr * my_error_ptr; * Here's the routine that will replace the standard error_exit method: */ -METHODDEF(void) -my_error_exit (j_common_ptr cinfo) +METHODDEF(void) my_error_exit (j_common_ptr cinfo) { /* cinfo->err really points to a my_error_mgr struct, so coerce pointer */ my_error_ptr myerr = (my_error_ptr) cinfo->err; @@ -177,6 +158,30 @@ my_error_exit (j_common_ptr cinfo) longjmp(myerr->setjmp_buffer, 1); } +void jpeg_wxio_src( j_decompress_ptr cinfo, wxInputStream& infile ) +{ + my_src_ptr src; + + if (cinfo->src == NULL) { /* first time for this JPEG object? */ + cinfo->src = (struct jpeg_source_mgr *) + (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, + sizeof(my_source_mgr)); + src = (my_src_ptr) cinfo->src; + } + src = (my_src_ptr) cinfo->src; + src->pub.bytes_in_buffer = 0; /* forces fill_input_buffer on first read */ + src->buffer = new JOCTET[JPEG_IO_BUFFER_SIZE]; + src->pub.next_input_byte = NULL; /* until buffer loaded */ + src->stream = &infile; + + src->pub.init_source = my_init_source; + src->pub.fill_input_buffer = my_fill_input_buffer; + src->pub.skip_input_data = my_skip_input_data; + src->pub.resync_to_restart = jpeg_resync_to_restart; /* use default method */ + src->pub.term_source = my_term_source; +} + + // temporarily disable the warning C4611 (interaction between '_setjmp' and // C++ object destruction is non-portable) - I don't see any dtors here #ifdef __VISUALC__ diff --git a/src/common/imagpng.cpp b/src/common/imagpng.cpp index c8054c25e4..b41838fa22 100644 --- a/src/common/imagpng.cpp +++ b/src/common/imagpng.cpp @@ -60,12 +60,15 @@ IMPLEMENT_DYNAMIC_CLASS(wxPNGHandler,wxImageHandler) #define PNGLINKAGEMODE LINKAGEMODE #endif -static void PNGLINKAGEMODE _PNG_stream_reader( png_structp png_ptr, png_bytep data, png_size_t length ) +extern "C" +{ + +void PNGLINKAGEMODE _PNG_stream_reader( png_structp png_ptr, png_bytep data, png_size_t length ) { ((wxInputStream*) png_get_io_ptr( png_ptr )) -> Read(data, length); } -static void PNGLINKAGEMODE _PNG_stream_writer( png_structp png_ptr, png_bytep data, png_size_t length ) +void PNGLINKAGEMODE _PNG_stream_writer( png_structp png_ptr, png_bytep data, png_size_t length ) { ((wxOutputStream*) png_get_io_ptr( png_ptr )) -> Write(data, length); } @@ -91,6 +94,8 @@ PNGLINKAGEMODE png_silent_warning(png_structp WXUNUSED(png_ptr), png_const_charp { } +} // extern "C" + // temporarily disable the warning C4611 (interaction between '_setjmp' and // C++ object destruction is non-portable) - I don't see any dtors here #ifdef __VISUALC__ diff --git a/src/common/imagtiff.cpp b/src/common/imagtiff.cpp index 989a1600a2..0c741c92c1 100644 --- a/src/common/imagtiff.cpp +++ b/src/common/imagtiff.cpp @@ -47,7 +47,10 @@ extern "C" IMPLEMENT_DYNAMIC_CLASS(wxTIFFHandler,wxImageHandler) -static tsize_t TIFFLINKAGEMODE +extern "C" +{ + +tsize_t TIFFLINKAGEMODE _tiffNullProc(thandle_t WXUNUSED(handle), tdata_t WXUNUSED(buf), tsize_t WXUNUSED(size)) @@ -55,7 +58,7 @@ _tiffNullProc(thandle_t WXUNUSED(handle), return (tsize_t) -1; } -static tsize_t TIFFLINKAGEMODE +tsize_t TIFFLINKAGEMODE _tiffReadProc(thandle_t handle, tdata_t buf, tsize_t size) { wxInputStream *stream = (wxInputStream*) handle; @@ -63,7 +66,7 @@ _tiffReadProc(thandle_t handle, tdata_t buf, tsize_t size) return stream->LastRead(); } -static tsize_t TIFFLINKAGEMODE +tsize_t TIFFLINKAGEMODE _tiffWriteProc(thandle_t handle, tdata_t buf, tsize_t size) { wxOutputStream *stream = (wxOutputStream*) handle; @@ -71,7 +74,7 @@ _tiffWriteProc(thandle_t handle, tdata_t buf, tsize_t size) return stream->LastWrite(); } -static toff_t TIFFLINKAGEMODE +toff_t TIFFLINKAGEMODE _tiffSeekIProc(thandle_t handle, toff_t off, int whence) { wxInputStream *stream = (wxInputStream*) handle; @@ -87,7 +90,7 @@ _tiffSeekIProc(thandle_t handle, toff_t off, int whence) return (toff_t)stream->SeekI( (off_t)off, mode ); } -static toff_t TIFFLINKAGEMODE +toff_t TIFFLINKAGEMODE _tiffSeekOProc(thandle_t handle, toff_t off, int whence) { wxOutputStream *stream = (wxOutputStream*) handle; @@ -103,20 +106,20 @@ _tiffSeekOProc(thandle_t handle, toff_t off, int whence) return (toff_t)stream->SeekO( (off_t)off, mode ); } -static int TIFFLINKAGEMODE +int TIFFLINKAGEMODE _tiffCloseProc(thandle_t WXUNUSED(handle)) { return 0; // ? } -static toff_t TIFFLINKAGEMODE +toff_t TIFFLINKAGEMODE _tiffSizeProc(thandle_t handle) { wxStreamBase *stream = (wxStreamBase*) handle; return (toff_t) stream->GetSize(); } -static int TIFFLINKAGEMODE +int TIFFLINKAGEMODE _tiffMapProc(thandle_t WXUNUSED(handle), tdata_t* WXUNUSED(pbase), toff_t* WXUNUSED(psize)) @@ -124,13 +127,15 @@ _tiffMapProc(thandle_t WXUNUSED(handle), return 0; } -static void TIFFLINKAGEMODE +void TIFFLINKAGEMODE _tiffUnmapProc(thandle_t WXUNUSED(handle), tdata_t WXUNUSED(base), toff_t WXUNUSED(size)) { } +} // extern "C" + TIFF* TIFFwxOpen(wxInputStream &stream, const char* name, const char* mode) { diff --git a/src/common/list.cpp b/src/common/list.cpp index 1d647ddd27..018d554add 100644 --- a/src/common/list.cpp +++ b/src/common/list.cpp @@ -640,7 +640,7 @@ bool wxStringList::Member(const wxChar *s) const return FALSE; } -static int LINKAGEMODE +extern "C" int LINKAGEMODE wx_comparestrings(const void *arg1, const void *arg2) { wxChar **s1 = (wxChar **) arg1; diff --git a/src/common/resource.cpp b/src/common/resource.cpp index a6446d9710..e012fd8929 100644 --- a/src/common/resource.cpp +++ b/src/common/resource.cpp @@ -2049,7 +2049,7 @@ wxChar* wxResourceParseWord(wxChar*s, int *i) struct wxResourceBitListStruct { - wxChar *word; + const wxChar *word; long bits; }; diff --git a/src/common/socket.cpp b/src/common/socket.cpp index 003bd9dbcf..9df24e42c9 100644 --- a/src/common/socket.cpp +++ b/src/common/socket.cpp @@ -862,9 +862,10 @@ char *wxSocketBase::CallbackData(char *data) // decoupled from wx_socket_callback and thus they suffer from a variety // of problems. Avoid them where possible and use events instead. -static void LINKAGEMODE wx_socket_callback(GSocket * WXUNUSED(socket), - GSocketEvent notification, - char *cdata) +extern "C" +void LINKAGEMODE wx_socket_callback(GSocket * WXUNUSED(socket), + GSocketEvent notification, + char *cdata) { wxSocketBase *sckobj = (wxSocketBase *)cdata; diff --git a/src/common/string.cpp b/src/common/string.cpp index b1349cf731..6bc1683a23 100644 --- a/src/common/string.cpp +++ b/src/common/string.cpp @@ -2240,7 +2240,8 @@ static wxArrayString::CompareFunction gs_compareFunction = NULL; static bool gs_sortAscending = TRUE; // function which is called by quick sort -static int LINKAGEMODE wxStringCompareFunction(const void *first, const void *second) +extern "C" int LINKAGEMODE +wxStringCompareFunction(const void *first, const void *second) { wxString *strFirst = (wxString *)first; wxString *strSecond = (wxString *)second; diff --git a/src/common/wxexpr.cpp b/src/common/wxexpr.cpp index 6f67df37a2..01784063b2 100644 --- a/src/common/wxexpr.cpp +++ b/src/common/wxexpr.cpp @@ -1255,7 +1255,7 @@ void process_command(char * cexpr) void syntax_error(char *WXUNUSED(s)) { if (currentwxExprErrorHandler) - (void)(*(currentwxExprErrorHandler))(WXEXPR_ERROR_SYNTAX, "syntax error"); + (void)(*(currentwxExprErrorHandler))(WXEXPR_ERROR_SYNTAX, (char *)"syntax error"); if (thewxExprDatabase) thewxExprDatabase->noErrors += 1; } diff --git a/src/common/xpmdecod.cpp b/src/common/xpmdecod.cpp index 6f593fc989..05113e9ab8 100644 --- a/src/common/xpmdecod.cpp +++ b/src/common/xpmdecod.cpp @@ -263,7 +263,7 @@ wxImage wxXPMDecoder::ReadFile(wxInputStream& stream) typedef struct { - char *name; + const char *name; wxUint32 rgb; } rgbRecord; diff --git a/src/generic/dirctrlg.cpp b/src/generic/dirctrlg.cpp index 9049f96c27..c0016cef79 100644 --- a/src/generic/dirctrlg.cpp +++ b/src/generic/dirctrlg.cpp @@ -90,7 +90,7 @@ #endif /* Closed folder */ -static char * icon1_xpm[] = { +static const char * icon1_xpm[] = { /* width height ncolors chars_per_pixel */ "16 16 6 1", /* colors */ @@ -119,7 +119,7 @@ static char * icon1_xpm[] = { " "}; /* Open folder */ -static char * icon2_xpm[] = { +static const char * icon2_xpm[] = { /* width height ncolors chars_per_pixel */ "16 16 6 1", /* colors */ @@ -148,7 +148,7 @@ static char * icon2_xpm[] = { " "}; /* File */ -static char * icon3_xpm[] = { +static const char * icon3_xpm[] = { /* width height ncolors chars_per_pixel */ "16 16 3 1", /* colors */ @@ -174,7 +174,7 @@ static char * icon3_xpm[] = { " "}; /* Computer */ -static char * icon4_xpm[] = { +static const char * icon4_xpm[] = { "16 16 7 1", " s None c None", ". c #808080", @@ -201,7 +201,7 @@ static char * icon4_xpm[] = { "............o "}; /* Drive */ -static char * icon5_xpm[] = { +static const char * icon5_xpm[] = { "16 16 7 1", " s None c None", ". c #808080", @@ -228,7 +228,7 @@ static char * icon5_xpm[] = { " "}; /* CD-ROM */ -static char *icon6_xpm[] = { +static const char *icon6_xpm[] = { "16 16 10 1", " s None c None", ". c #808080", @@ -258,7 +258,7 @@ static char *icon6_xpm[] = { " "}; /* Floppy */ -static char * icon7_xpm[] = { +static const char * icon7_xpm[] = { "16 16 7 1", " s None c None", ". c #808080", @@ -285,7 +285,7 @@ static char * icon7_xpm[] = { " "}; /* Removeable */ -static char * icon8_xpm[] = { +static const char * icon8_xpm[] = { "16 16 7 1", " s None c None", ". c #808080", diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index f61435dac0..9e22abf5a0 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -1804,7 +1804,8 @@ void wxListHeaderWindow::DoDrawRect( wxDC *dc, int x, int y, int w, int h ) gtk_paint_box (m_wxwindow->style, GTK_PIZZA(m_wxwindow)->bin_window, state, GTK_SHADOW_OUT, - (GdkRectangle*) NULL, m_wxwindow, "button", + (GdkRectangle*) NULL, m_wxwindow, + (char *)"button", // const_cast x-1, y-1, w+2, h+2); #elif defined( __WXMAC__ ) const int m_corner = 1; diff --git a/src/gtk/app.cpp b/src/gtk/app.cpp index f66454123e..daa4e27b35 100644 --- a/src/gtk/app.cpp +++ b/src/gtk/app.cpp @@ -61,14 +61,15 @@ static GtkWidget *gs_RootWindow = (GtkWidget*) NULL; // local functions //----------------------------------------------------------------------------- -/* forward declaration */ -gint wxapp_idle_callback( gpointer WXUNUSED(data) ); -gint wxapp_pending_callback( gpointer WXUNUSED(data) ); -void wxapp_install_idle_handler(); +extern "C" +{ + gint wxapp_idle_callback( gpointer WXUNUSED(data) ); + gint wxapp_pending_callback( gpointer WXUNUSED(data) ); +} -#if wxUSE_THREADS -gint wxapp_wakeup_timerout_callback( gpointer WXUNUSED(data) ); -#endif +void wxapp_install_thread_wakeup(); +void wxapp_uninstall_thread_wakeup(); +void wxapp_install_idle_handler(); //----------------------------------------------------------------------------- // wxExit @@ -163,6 +164,28 @@ void wxWakeUpIdle() // local functions //----------------------------------------------------------------------------- +void wxapp_install_idle_handler() +{ + wxASSERT_MSG( wxTheApp->m_idleTag == 0, wxT("attempt to install idle handler twice") ); + + g_isIdle = FALSE; + + if (g_pendingTag == 0) + g_pendingTag = gtk_idle_add_priority( 900, wxapp_pending_callback, (gpointer) NULL ); + + /* This routine gets called by all event handlers + indicating that the idle is over. It may also + get called from other thread for sending events + to the main thread (and processing these in + idle time). Very low priority. */ + + wxTheApp->m_idleTag = gtk_idle_add_priority( 1000, wxapp_idle_callback, (gpointer) NULL ); +} + +// the callback functions must be extern "C" to comply with GTK+ declarations +extern "C" +{ + gint wxapp_pending_callback( gpointer WXUNUSED(data) ) { if (!wxTheApp) return TRUE; @@ -230,24 +253,42 @@ gint wxapp_idle_callback( gpointer WXUNUSED(data) ) return FALSE; } -void wxapp_install_idle_handler() +#if wxUSE_THREADS + +gint wxapp_wakeup_timerout_callback( gpointer WXUNUSED(data) ) { - wxASSERT_MSG( wxTheApp->m_idleTag == 0, wxT("attempt to install idle handler twice") ); + // when getting called from GDK's time-out handler + // we are no longer within GDK's grab on the GUI + // thread so we must lock it here ourselves + gdk_threads_enter(); - g_isIdle = FALSE; + wxapp_uninstall_thread_wakeup(); - if (g_pendingTag == 0) - g_pendingTag = gtk_idle_add_priority( 900, wxapp_pending_callback, (gpointer) NULL ); + // unblock other threads wishing to do some GUI things + wxMutexGuiLeave(); - /* This routine gets called by all event handlers - indicating that the idle is over. It may also - get called from other thread for sending events - to the main thread (and processing these in - idle time). Very low priority. */ + g_mainThreadLocked = TRUE; - wxTheApp->m_idleTag = gtk_idle_add_priority( 1000, wxapp_idle_callback, (gpointer) NULL ); + // wake up other threads + wxUsleep( 1 ); + + // block other thread again + wxMutexGuiEnter(); + + g_mainThreadLocked = FALSE; + + wxapp_install_thread_wakeup(); + + // release lock again + gdk_threads_leave(); + + return TRUE; } +#endif // wxUSE_THREADS + +} // extern "C" + #if wxUSE_THREADS static int g_threadUninstallLevel = 0; @@ -275,36 +316,6 @@ void wxapp_uninstall_thread_wakeup() wxTheApp->m_wakeUpTimerTag = 0; } -gint wxapp_wakeup_timerout_callback( gpointer WXUNUSED(data) ) -{ - // when getting called from GDK's time-out handler - // we are no longer within GDK's grab on the GUI - // thread so we must lock it here ourselves - gdk_threads_enter(); - - wxapp_uninstall_thread_wakeup(); - - // unblock other threads wishing to do some GUI things - wxMutexGuiLeave(); - - g_mainThreadLocked = TRUE; - - // wake up other threads - wxUsleep( 1 ); - - // block other thread again - wxMutexGuiEnter(); - - g_mainThreadLocked = FALSE; - - wxapp_install_thread_wakeup(); - - // release lock again - gdk_threads_leave(); - - return TRUE; -} - #endif // wxUSE_THREADS //----------------------------------------------------------------------------- diff --git a/src/gtk/dnd.cpp b/src/gtk/dnd.cpp index 5d4111c304..59a3c3a947 100644 --- a/src/gtk/dnd.cpp +++ b/src/gtk/dnd.cpp @@ -60,7 +60,7 @@ static const wxChar *TRACE_DND = _T("dnd"); //---------------------------------------------------------------------------- /* XPM */ -static char * page_xpm[] = { +static const char * page_xpm[] = { /* width height ncolors chars_per_pixel */ "32 32 5 1", /* colors */ diff --git a/src/gtk/menu.cpp b/src/gtk/menu.cpp index 9c28eb232c..77ac32a68d 100644 --- a/src/gtk/menu.cpp +++ b/src/gtk/menu.cpp @@ -322,7 +322,7 @@ bool wxMenuBar::GtkAppend(wxMenu *menu, const wxString& title) entry.accelerator = (gchar*) NULL; entry.callback = (GtkItemFactoryCallback) NULL; entry.callback_action = 0; - entry.item_type = ""; + entry.item_type = (char *)""; gtk_item_factory_create_item( m_factory, &entry, (gpointer) this, 2 ); /* what is 2 ? */ /* in order to get the pointer to the item we need the item text _without_ underscores */ @@ -886,10 +886,10 @@ void wxMenu::Init() if(m_style & wxMENU_TEAROFF) { GtkItemFactoryEntry entry; - entry.path = "/tearoff"; + entry.path = (char *)"/tearoff"; entry.callback = (GtkItemFactoryCallback) NULL; entry.callback_action = 0; - entry.item_type = ""; + entry.item_type = (char *)""; entry.accelerator = (gchar*) NULL; gtk_item_factory_create_item( m_factory, &entry, (gpointer) this, 2 ); /* what is 2 ? */ //GtkWidget *menuItem = gtk_item_factory_get_widget( m_factory, "
/tearoff" ); @@ -923,10 +923,10 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem) { #if (GTK_MINOR_VERSION > 0) GtkItemFactoryEntry entry; - entry.path = "/sep"; + entry.path = (char *)"/sep"; entry.callback = (GtkItemFactoryCallback) NULL; entry.callback_action = 0; - entry.item_type = ""; + entry.item_type = (char *)""; entry.accelerator = (gchar*) NULL; gtk_item_factory_create_item( m_factory, &entry, (gpointer) this, 2 ); /* what is 2 ? */ @@ -952,7 +952,7 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem) entry.path = buf; entry.callback = (GtkItemFactoryCallback) 0; entry.callback_action = 0; - entry.item_type = ""; + entry.item_type = (char *)""; entry.accelerator = (gchar*) NULL; gtk_item_factory_create_item( m_factory, &entry, (gpointer) this, 2 ); /* what is 2 ? */ @@ -1022,9 +1022,9 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem) entry.callback = (GtkItemFactoryCallback) gtk_menu_clicked_callback; entry.callback_action = 0; if ( mitem->IsCheckable() ) - entry.item_type = ""; + entry.item_type = (char *)""; else - entry.item_type = ""; + entry.item_type = (char *)""; entry.accelerator = (gchar*) NULL; #if wxUSE_ACCEL @@ -1251,6 +1251,9 @@ static wxString GetHotKey( const wxMenuItem& item ) #include #include +extern "C" +{ + static void gtk_pixmap_menu_item_class_init (GtkPixmapMenuItemClass *klass); static void gtk_pixmap_menu_item_init (GtkPixmapMenuItem *menu_item); static void gtk_pixmap_menu_item_draw (GtkWidget *widget, @@ -1276,6 +1279,8 @@ static void changed_have_pixmap_status (GtkPixmapMenuItem *menu_item); static GtkMenuItemClass *parent_class = NULL; +} + #define BORDER_SPACING 3 #define PMAP_WIDTH 20 @@ -1288,7 +1293,7 @@ gtk_pixmap_menu_item_get_type (void) { GtkTypeInfo pixmap_menu_item_info = { - "GtkPixmapMenuItem", + (char *)"GtkPixmapMenuItem", sizeof (GtkPixmapMenuItem), sizeof (GtkPixmapMenuItemClass), (GtkClassInitFunc) gtk_pixmap_menu_item_class_init, diff --git a/src/gtk/minifram.cpp b/src/gtk/minifram.cpp index 8e823f312b..53d01860b9 100644 --- a/src/gtk/minifram.cpp +++ b/src/gtk/minifram.cpp @@ -270,7 +270,7 @@ static void gtk_button_clicked_callback( GtkWidget *WXUNUSED(widget), wxMiniFram // wxMiniFrame //----------------------------------------------------------------------------- -static char *cross_xpm[] = { +static const char *cross_xpm[] = { /* columns rows colors chars-per-pixel */ "5 5 16 1", " c Gray0", @@ -321,7 +321,13 @@ bool wxMiniFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title ((style & wxCAPTION) || (style & wxTINY_CAPTION_HORIZ) || (style & wxTINY_CAPTION_VERT))) { GdkBitmap *mask = (GdkBitmap*) NULL; - GdkPixmap *pixmap = gdk_pixmap_create_from_xpm_d( wxGetRootWindow()->window, &mask, NULL, cross_xpm ); + GdkPixmap *pixmap = gdk_pixmap_create_from_xpm_d + ( + wxGetRootWindow()->window, + &mask, + NULL, + (char **)cross_xpm + ); GtkWidget *pw = gtk_pixmap_new( pixmap, mask ); gdk_bitmap_unref( mask ); diff --git a/src/gtk/timer.cpp b/src/gtk/timer.cpp index 2afdb78df9..a8514f8cd1 100644 --- a/src/gtk/timer.cpp +++ b/src/gtk/timer.cpp @@ -26,7 +26,7 @@ IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxObject) -static gint timeout_callback( gpointer data ) +extern "C" gint timeout_callback( gpointer data ) { wxTimer *timer = (wxTimer*)data; diff --git a/src/gtk/toplevel.cpp b/src/gtk/toplevel.cpp index 499a36e689..28f810cdf2 100644 --- a/src/gtk/toplevel.cpp +++ b/src/gtk/toplevel.cpp @@ -245,8 +245,13 @@ static int gtk_window_expose_callback( GtkWidget *widget, GdkEventExpose *gdk_ev { GtkPizza *pizza = GTK_PIZZA(widget); - gtk_paint_flat_box (win->m_widget->style, pizza->bin_window, GTK_STATE_NORMAL, - GTK_SHADOW_NONE, &gdk_event->area, win->m_widget, "base", 0, 0, -1, -1); + gtk_paint_flat_box (win->m_widget->style, + pizza->bin_window, GTK_STATE_NORMAL, + GTK_SHADOW_NONE, + &gdk_event->area, + win->m_widget, + (char *)"base", + 0, 0, -1, -1); return TRUE; } @@ -260,8 +265,13 @@ static void gtk_window_draw_callback( GtkWidget *widget, GdkRectangle *rect, wxW { GtkPizza *pizza = GTK_PIZZA(widget); - gtk_paint_flat_box (win->m_widget->style, pizza->bin_window, GTK_STATE_NORMAL, - GTK_SHADOW_NONE, rect, win->m_widget, "base", 0, 0, -1, -1); + gtk_paint_flat_box (win->m_widget->style, + pizza->bin_window, GTK_STATE_NORMAL, + GTK_SHADOW_NONE, + rect, + win->m_widget, + (char *)"base", + 0, 0, -1, -1); } // ---------------------------------------------------------------------------- diff --git a/src/gtk/utilsgtk.cpp b/src/gtk/utilsgtk.cpp index 1296a0f762..1bc1106f93 100644 --- a/src/gtk/utilsgtk.cpp +++ b/src/gtk/utilsgtk.cpp @@ -139,8 +139,9 @@ wxWindow* wxFindWindowAtPoint(const wxPoint& pt) // subprocess routines // ---------------------------------------------------------------------------- -static void GTK_EndProcessDetector(gpointer data, gint source, - GdkInputCondition WXUNUSED(condition) ) +extern "C" +void GTK_EndProcessDetector(gpointer data, gint source, + GdkInputCondition WXUNUSED(condition) ) { wxEndProcessData *proc_data = (wxEndProcessData *)data; diff --git a/src/gtk/win_gtk.c b/src/gtk/win_gtk.c index 2f41b1064c..db9045e73e 100644 --- a/src/gtk/win_gtk.c +++ b/src/gtk/win_gtk.c @@ -852,7 +852,7 @@ gtk_pizza_forall (GtkContainer *container, g_return_if_fail (container != NULL); g_return_if_fail (GTK_IS_PIZZA (container)); - g_return_if_fail (callback != NULL); + g_return_if_fail (callback != (GtkCallback)NULL); pizza = GTK_PIZZA (container); diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index d3f6cf1e1c..ccb09b9a12 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -785,8 +785,14 @@ static int gtk_window_expose_callback( GtkWidget *widget, if (!parent) parent = win; - gtk_paint_flat_box (parent->m_widget->style, pizza->bin_window, GTK_STATE_NORMAL, - GTK_SHADOW_NONE, &gdk_event->area, parent->m_widget, "base", 0, 0, -1, -1); + gtk_paint_flat_box (parent->m_widget->style, + pizza->bin_window, + GTK_STATE_NORMAL, + GTK_SHADOW_NONE, + &gdk_event->area, + parent->m_widget, + (char *)"base", + 0, 0, -1, -1); } win->GetUpdateRegion().Union( gdk_event->area.x, @@ -928,8 +934,14 @@ static void gtk_window_draw_callback( GtkWidget *widget, if (!parent) parent = win; - gtk_paint_flat_box (parent->m_widget->style, pizza->bin_window, GTK_STATE_NORMAL, - GTK_SHADOW_NONE, rect, parent->m_widget, "base", 0, 0, -1, -1); + gtk_paint_flat_box (parent->m_widget->style, + pizza->bin_window, + GTK_STATE_NORMAL, + GTK_SHADOW_NONE, + rect, + parent->m_widget, + (char *)"base", + 0, 0, -1, -1); } @@ -3713,7 +3725,8 @@ void wxWindowGTK::ApplyWidgetStyle() #if wxUSE_MENUS_NATIVE -static void gtk_pop_hide_callback( GtkWidget *WXUNUSED(widget), bool* is_waiting ) +extern "C" +void gtk_pop_hide_callback( GtkWidget *WXUNUSED(widget), bool* is_waiting ) { *is_waiting = FALSE; } @@ -3775,8 +3788,10 @@ bool wxWindowGTK::DoPopupMenu( wxMenu *menu, int x, int y ) bool is_waiting = TRUE; - gtk_signal_connect( GTK_OBJECT(menu->m_menu), "hide", - GTK_SIGNAL_FUNC(gtk_pop_hide_callback), (gpointer)&is_waiting ); + gtk_signal_connect( GTK_OBJECT(menu->m_menu), + "hide", + GTK_SIGNAL_FUNC(gtk_pop_hide_callback), + (gpointer)&is_waiting ); gtk_menu_popup( GTK_MENU(menu->m_menu), diff --git a/src/gtk1/app.cpp b/src/gtk1/app.cpp index f66454123e..daa4e27b35 100644 --- a/src/gtk1/app.cpp +++ b/src/gtk1/app.cpp @@ -61,14 +61,15 @@ static GtkWidget *gs_RootWindow = (GtkWidget*) NULL; // local functions //----------------------------------------------------------------------------- -/* forward declaration */ -gint wxapp_idle_callback( gpointer WXUNUSED(data) ); -gint wxapp_pending_callback( gpointer WXUNUSED(data) ); -void wxapp_install_idle_handler(); +extern "C" +{ + gint wxapp_idle_callback( gpointer WXUNUSED(data) ); + gint wxapp_pending_callback( gpointer WXUNUSED(data) ); +} -#if wxUSE_THREADS -gint wxapp_wakeup_timerout_callback( gpointer WXUNUSED(data) ); -#endif +void wxapp_install_thread_wakeup(); +void wxapp_uninstall_thread_wakeup(); +void wxapp_install_idle_handler(); //----------------------------------------------------------------------------- // wxExit @@ -163,6 +164,28 @@ void wxWakeUpIdle() // local functions //----------------------------------------------------------------------------- +void wxapp_install_idle_handler() +{ + wxASSERT_MSG( wxTheApp->m_idleTag == 0, wxT("attempt to install idle handler twice") ); + + g_isIdle = FALSE; + + if (g_pendingTag == 0) + g_pendingTag = gtk_idle_add_priority( 900, wxapp_pending_callback, (gpointer) NULL ); + + /* This routine gets called by all event handlers + indicating that the idle is over. It may also + get called from other thread for sending events + to the main thread (and processing these in + idle time). Very low priority. */ + + wxTheApp->m_idleTag = gtk_idle_add_priority( 1000, wxapp_idle_callback, (gpointer) NULL ); +} + +// the callback functions must be extern "C" to comply with GTK+ declarations +extern "C" +{ + gint wxapp_pending_callback( gpointer WXUNUSED(data) ) { if (!wxTheApp) return TRUE; @@ -230,24 +253,42 @@ gint wxapp_idle_callback( gpointer WXUNUSED(data) ) return FALSE; } -void wxapp_install_idle_handler() +#if wxUSE_THREADS + +gint wxapp_wakeup_timerout_callback( gpointer WXUNUSED(data) ) { - wxASSERT_MSG( wxTheApp->m_idleTag == 0, wxT("attempt to install idle handler twice") ); + // when getting called from GDK's time-out handler + // we are no longer within GDK's grab on the GUI + // thread so we must lock it here ourselves + gdk_threads_enter(); - g_isIdle = FALSE; + wxapp_uninstall_thread_wakeup(); - if (g_pendingTag == 0) - g_pendingTag = gtk_idle_add_priority( 900, wxapp_pending_callback, (gpointer) NULL ); + // unblock other threads wishing to do some GUI things + wxMutexGuiLeave(); - /* This routine gets called by all event handlers - indicating that the idle is over. It may also - get called from other thread for sending events - to the main thread (and processing these in - idle time). Very low priority. */ + g_mainThreadLocked = TRUE; - wxTheApp->m_idleTag = gtk_idle_add_priority( 1000, wxapp_idle_callback, (gpointer) NULL ); + // wake up other threads + wxUsleep( 1 ); + + // block other thread again + wxMutexGuiEnter(); + + g_mainThreadLocked = FALSE; + + wxapp_install_thread_wakeup(); + + // release lock again + gdk_threads_leave(); + + return TRUE; } +#endif // wxUSE_THREADS + +} // extern "C" + #if wxUSE_THREADS static int g_threadUninstallLevel = 0; @@ -275,36 +316,6 @@ void wxapp_uninstall_thread_wakeup() wxTheApp->m_wakeUpTimerTag = 0; } -gint wxapp_wakeup_timerout_callback( gpointer WXUNUSED(data) ) -{ - // when getting called from GDK's time-out handler - // we are no longer within GDK's grab on the GUI - // thread so we must lock it here ourselves - gdk_threads_enter(); - - wxapp_uninstall_thread_wakeup(); - - // unblock other threads wishing to do some GUI things - wxMutexGuiLeave(); - - g_mainThreadLocked = TRUE; - - // wake up other threads - wxUsleep( 1 ); - - // block other thread again - wxMutexGuiEnter(); - - g_mainThreadLocked = FALSE; - - wxapp_install_thread_wakeup(); - - // release lock again - gdk_threads_leave(); - - return TRUE; -} - #endif // wxUSE_THREADS //----------------------------------------------------------------------------- diff --git a/src/gtk1/dnd.cpp b/src/gtk1/dnd.cpp index 5d4111c304..59a3c3a947 100644 --- a/src/gtk1/dnd.cpp +++ b/src/gtk1/dnd.cpp @@ -60,7 +60,7 @@ static const wxChar *TRACE_DND = _T("dnd"); //---------------------------------------------------------------------------- /* XPM */ -static char * page_xpm[] = { +static const char * page_xpm[] = { /* width height ncolors chars_per_pixel */ "32 32 5 1", /* colors */ diff --git a/src/gtk1/menu.cpp b/src/gtk1/menu.cpp index 9c28eb232c..77ac32a68d 100644 --- a/src/gtk1/menu.cpp +++ b/src/gtk1/menu.cpp @@ -322,7 +322,7 @@ bool wxMenuBar::GtkAppend(wxMenu *menu, const wxString& title) entry.accelerator = (gchar*) NULL; entry.callback = (GtkItemFactoryCallback) NULL; entry.callback_action = 0; - entry.item_type = ""; + entry.item_type = (char *)""; gtk_item_factory_create_item( m_factory, &entry, (gpointer) this, 2 ); /* what is 2 ? */ /* in order to get the pointer to the item we need the item text _without_ underscores */ @@ -886,10 +886,10 @@ void wxMenu::Init() if(m_style & wxMENU_TEAROFF) { GtkItemFactoryEntry entry; - entry.path = "/tearoff"; + entry.path = (char *)"/tearoff"; entry.callback = (GtkItemFactoryCallback) NULL; entry.callback_action = 0; - entry.item_type = ""; + entry.item_type = (char *)""; entry.accelerator = (gchar*) NULL; gtk_item_factory_create_item( m_factory, &entry, (gpointer) this, 2 ); /* what is 2 ? */ //GtkWidget *menuItem = gtk_item_factory_get_widget( m_factory, "
/tearoff" ); @@ -923,10 +923,10 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem) { #if (GTK_MINOR_VERSION > 0) GtkItemFactoryEntry entry; - entry.path = "/sep"; + entry.path = (char *)"/sep"; entry.callback = (GtkItemFactoryCallback) NULL; entry.callback_action = 0; - entry.item_type = ""; + entry.item_type = (char *)""; entry.accelerator = (gchar*) NULL; gtk_item_factory_create_item( m_factory, &entry, (gpointer) this, 2 ); /* what is 2 ? */ @@ -952,7 +952,7 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem) entry.path = buf; entry.callback = (GtkItemFactoryCallback) 0; entry.callback_action = 0; - entry.item_type = ""; + entry.item_type = (char *)""; entry.accelerator = (gchar*) NULL; gtk_item_factory_create_item( m_factory, &entry, (gpointer) this, 2 ); /* what is 2 ? */ @@ -1022,9 +1022,9 @@ bool wxMenu::GtkAppend(wxMenuItem *mitem) entry.callback = (GtkItemFactoryCallback) gtk_menu_clicked_callback; entry.callback_action = 0; if ( mitem->IsCheckable() ) - entry.item_type = ""; + entry.item_type = (char *)""; else - entry.item_type = ""; + entry.item_type = (char *)""; entry.accelerator = (gchar*) NULL; #if wxUSE_ACCEL @@ -1251,6 +1251,9 @@ static wxString GetHotKey( const wxMenuItem& item ) #include #include +extern "C" +{ + static void gtk_pixmap_menu_item_class_init (GtkPixmapMenuItemClass *klass); static void gtk_pixmap_menu_item_init (GtkPixmapMenuItem *menu_item); static void gtk_pixmap_menu_item_draw (GtkWidget *widget, @@ -1276,6 +1279,8 @@ static void changed_have_pixmap_status (GtkPixmapMenuItem *menu_item); static GtkMenuItemClass *parent_class = NULL; +} + #define BORDER_SPACING 3 #define PMAP_WIDTH 20 @@ -1288,7 +1293,7 @@ gtk_pixmap_menu_item_get_type (void) { GtkTypeInfo pixmap_menu_item_info = { - "GtkPixmapMenuItem", + (char *)"GtkPixmapMenuItem", sizeof (GtkPixmapMenuItem), sizeof (GtkPixmapMenuItemClass), (GtkClassInitFunc) gtk_pixmap_menu_item_class_init, diff --git a/src/gtk1/minifram.cpp b/src/gtk1/minifram.cpp index 8e823f312b..53d01860b9 100644 --- a/src/gtk1/minifram.cpp +++ b/src/gtk1/minifram.cpp @@ -270,7 +270,7 @@ static void gtk_button_clicked_callback( GtkWidget *WXUNUSED(widget), wxMiniFram // wxMiniFrame //----------------------------------------------------------------------------- -static char *cross_xpm[] = { +static const char *cross_xpm[] = { /* columns rows colors chars-per-pixel */ "5 5 16 1", " c Gray0", @@ -321,7 +321,13 @@ bool wxMiniFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title ((style & wxCAPTION) || (style & wxTINY_CAPTION_HORIZ) || (style & wxTINY_CAPTION_VERT))) { GdkBitmap *mask = (GdkBitmap*) NULL; - GdkPixmap *pixmap = gdk_pixmap_create_from_xpm_d( wxGetRootWindow()->window, &mask, NULL, cross_xpm ); + GdkPixmap *pixmap = gdk_pixmap_create_from_xpm_d + ( + wxGetRootWindow()->window, + &mask, + NULL, + (char **)cross_xpm + ); GtkWidget *pw = gtk_pixmap_new( pixmap, mask ); gdk_bitmap_unref( mask ); diff --git a/src/gtk1/timer.cpp b/src/gtk1/timer.cpp index 2afdb78df9..a8514f8cd1 100644 --- a/src/gtk1/timer.cpp +++ b/src/gtk1/timer.cpp @@ -26,7 +26,7 @@ IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxObject) -static gint timeout_callback( gpointer data ) +extern "C" gint timeout_callback( gpointer data ) { wxTimer *timer = (wxTimer*)data; diff --git a/src/gtk1/toplevel.cpp b/src/gtk1/toplevel.cpp index 499a36e689..28f810cdf2 100644 --- a/src/gtk1/toplevel.cpp +++ b/src/gtk1/toplevel.cpp @@ -245,8 +245,13 @@ static int gtk_window_expose_callback( GtkWidget *widget, GdkEventExpose *gdk_ev { GtkPizza *pizza = GTK_PIZZA(widget); - gtk_paint_flat_box (win->m_widget->style, pizza->bin_window, GTK_STATE_NORMAL, - GTK_SHADOW_NONE, &gdk_event->area, win->m_widget, "base", 0, 0, -1, -1); + gtk_paint_flat_box (win->m_widget->style, + pizza->bin_window, GTK_STATE_NORMAL, + GTK_SHADOW_NONE, + &gdk_event->area, + win->m_widget, + (char *)"base", + 0, 0, -1, -1); return TRUE; } @@ -260,8 +265,13 @@ static void gtk_window_draw_callback( GtkWidget *widget, GdkRectangle *rect, wxW { GtkPizza *pizza = GTK_PIZZA(widget); - gtk_paint_flat_box (win->m_widget->style, pizza->bin_window, GTK_STATE_NORMAL, - GTK_SHADOW_NONE, rect, win->m_widget, "base", 0, 0, -1, -1); + gtk_paint_flat_box (win->m_widget->style, + pizza->bin_window, GTK_STATE_NORMAL, + GTK_SHADOW_NONE, + rect, + win->m_widget, + (char *)"base", + 0, 0, -1, -1); } // ---------------------------------------------------------------------------- diff --git a/src/gtk1/utilsgtk.cpp b/src/gtk1/utilsgtk.cpp index 1296a0f762..1bc1106f93 100644 --- a/src/gtk1/utilsgtk.cpp +++ b/src/gtk1/utilsgtk.cpp @@ -139,8 +139,9 @@ wxWindow* wxFindWindowAtPoint(const wxPoint& pt) // subprocess routines // ---------------------------------------------------------------------------- -static void GTK_EndProcessDetector(gpointer data, gint source, - GdkInputCondition WXUNUSED(condition) ) +extern "C" +void GTK_EndProcessDetector(gpointer data, gint source, + GdkInputCondition WXUNUSED(condition) ) { wxEndProcessData *proc_data = (wxEndProcessData *)data; diff --git a/src/gtk1/win_gtk.c b/src/gtk1/win_gtk.c index 2f41b1064c..db9045e73e 100644 --- a/src/gtk1/win_gtk.c +++ b/src/gtk1/win_gtk.c @@ -852,7 +852,7 @@ gtk_pizza_forall (GtkContainer *container, g_return_if_fail (container != NULL); g_return_if_fail (GTK_IS_PIZZA (container)); - g_return_if_fail (callback != NULL); + g_return_if_fail (callback != (GtkCallback)NULL); pizza = GTK_PIZZA (container); diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index d3f6cf1e1c..ccb09b9a12 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -785,8 +785,14 @@ static int gtk_window_expose_callback( GtkWidget *widget, if (!parent) parent = win; - gtk_paint_flat_box (parent->m_widget->style, pizza->bin_window, GTK_STATE_NORMAL, - GTK_SHADOW_NONE, &gdk_event->area, parent->m_widget, "base", 0, 0, -1, -1); + gtk_paint_flat_box (parent->m_widget->style, + pizza->bin_window, + GTK_STATE_NORMAL, + GTK_SHADOW_NONE, + &gdk_event->area, + parent->m_widget, + (char *)"base", + 0, 0, -1, -1); } win->GetUpdateRegion().Union( gdk_event->area.x, @@ -928,8 +934,14 @@ static void gtk_window_draw_callback( GtkWidget *widget, if (!parent) parent = win; - gtk_paint_flat_box (parent->m_widget->style, pizza->bin_window, GTK_STATE_NORMAL, - GTK_SHADOW_NONE, rect, parent->m_widget, "base", 0, 0, -1, -1); + gtk_paint_flat_box (parent->m_widget->style, + pizza->bin_window, + GTK_STATE_NORMAL, + GTK_SHADOW_NONE, + rect, + parent->m_widget, + (char *)"base", + 0, 0, -1, -1); } @@ -3713,7 +3725,8 @@ void wxWindowGTK::ApplyWidgetStyle() #if wxUSE_MENUS_NATIVE -static void gtk_pop_hide_callback( GtkWidget *WXUNUSED(widget), bool* is_waiting ) +extern "C" +void gtk_pop_hide_callback( GtkWidget *WXUNUSED(widget), bool* is_waiting ) { *is_waiting = FALSE; } @@ -3775,8 +3788,10 @@ bool wxWindowGTK::DoPopupMenu( wxMenu *menu, int x, int y ) bool is_waiting = TRUE; - gtk_signal_connect( GTK_OBJECT(menu->m_menu), "hide", - GTK_SIGNAL_FUNC(gtk_pop_hide_callback), (gpointer)&is_waiting ); + gtk_signal_connect( GTK_OBJECT(menu->m_menu), + "hide", + GTK_SIGNAL_FUNC(gtk_pop_hide_callback), + (gpointer)&is_waiting ); gtk_menu_popup( GTK_MENU(menu->m_menu), diff --git a/src/html/helpdata.cpp b/src/html/helpdata.cpp index 11af5d51dc..acb90ff60c 100644 --- a/src/html/helpdata.cpp +++ b/src/html/helpdata.cpp @@ -61,7 +61,8 @@ static char* ReadLine(char *line, char *buf) -static int LINKAGEMODE IndexCompareFunc(const void *a, const void *b) +extern "C" int LINKAGEMODE +wxHtmlHelpIndexCompareFunc(const void *a, const void *b) { return wxStricmp(((wxHtmlContentsItem*)a)->m_Name, ((wxHtmlContentsItem*)b)->m_Name); } @@ -524,7 +525,7 @@ bool wxHtmlHelpData::AddBookParam(const wxFSFile& bookfile, m_BookRecords.Add(bookr); if (m_IndexCnt > 0) - qsort(m_Index, m_IndexCnt, sizeof(wxHtmlContentsItem), IndexCompareFunc); + qsort(m_Index, m_IndexCnt, sizeof(wxHtmlContentsItem), wxHtmlHelpIndexCompareFunc); return TRUE; } diff --git a/src/html/htmlpars.cpp b/src/html/htmlpars.cpp index 09f7c0ecd9..9efd706bea 100644 --- a/src/html/htmlpars.cpp +++ b/src/html/htmlpars.cpp @@ -491,7 +491,7 @@ struct wxHtmlEntityInfo unsigned code; }; -static int LINKAGEMODE compar_entity(const void *key, const void *item) +extern "C" int LINKAGEMODE wxHtmlEntityCompare(const void *key, const void *item) { return wxStrcmp((wxChar*)key, ((wxHtmlEntityInfo*)item)->name); } @@ -801,7 +801,7 @@ wxChar wxHtmlEntitiesParser::GetEntityChar(const wxString& entity) info = (wxHtmlEntityInfo*) bsearch(entity.c_str(), substitutions, substitutions_cnt, sizeof(wxHtmlEntityInfo), - compar_entity); + wxHtmlEntityCompare); if (info) code = info->code; } diff --git a/src/html/htmltag.cpp b/src/html/htmltag.cpp index e725a033ab..85fa7286ee 100644 --- a/src/html/htmltag.cpp +++ b/src/html/htmltag.cpp @@ -332,7 +332,9 @@ wxString wxHtmlTag::GetParam(const wxString& par, bool with_commas) const return m_ParamValues[index]; } -int wxHtmlTag::ScanParam(const wxString& par, wxChar *format, void *param) const +int wxHtmlTag::ScanParam(const wxString& par, + const wxChar *format, + void *param) const { wxString parval = GetParam(par); return wxSscanf(parval, format, param); diff --git a/src/unix/threadpsx.cpp b/src/unix/threadpsx.cpp index 14edbfc078..fd9b12c731 100644 --- a/src/unix/threadpsx.cpp +++ b/src/unix/threadpsx.cpp @@ -490,6 +490,13 @@ void wxCondition::Broadcast() // wxThread (Posix implementation) //-------------------------------------------------------------------- +#if HAVE_THREAD_CLEANUP_FUNCTIONS + +// thread exit function +extern "C" void wxPthreadCleanup(void *ptr); + +#endif // HAVE_THREAD_CLEANUP_FUNCTIONS + class wxThreadInternal { public: @@ -499,11 +506,6 @@ public: // thread entry function static void *PthreadStart(void *ptr); -#if HAVE_THREAD_CLEANUP_FUNCTIONS - // thread exit function - static void PthreadCleanup(void *ptr); -#endif - // thread actions // start the thread wxThreadError Run(); @@ -549,6 +551,11 @@ public: // sometimes - tell the thread that it should do it void Notify() { m_shouldBroadcast = TRUE; } +#if HAVE_THREAD_CLEANUP_FUNCTIONS + // this is used by wxPthreadCleanup() only + static void Cleanup(wxThread *thread); +#endif // HAVE_THREAD_CLEANUP_FUNCTIONS + private: pthread_t m_threadId; // id of the thread wxThreadState m_state; // see wxThreadState enum @@ -615,7 +622,7 @@ void *wxThreadInternal::PthreadStart(void *ptr) #if HAVE_THREAD_CLEANUP_FUNCTIONS // install the cleanup handler which will be called if the thread is // cancelled - pthread_cleanup_push(wxThreadInternal::PthreadCleanup, ptr); + pthread_cleanup_push(wxPthreadCleanup, ptr); #endif // HAVE_THREAD_CLEANUP_FUNCTIONS // wait for the condition to be signaled from Run() @@ -645,7 +652,7 @@ void *wxThreadInternal::PthreadStart(void *ptr) pthread->GetId()); // change the state of the thread to "exited" so that - // PthreadCleanup handler won't do anything from now (if it's + // wxPthreadCleanup handler won't do anything from now (if it's // called before we do pthread_cleanup_pop below) pthread->SetState(STATE_EXITED); } @@ -679,10 +686,13 @@ void *wxThreadInternal::PthreadStart(void *ptr) #if HAVE_THREAD_CLEANUP_FUNCTIONS // this handler is called when the thread is cancelled -void wxThreadInternal::PthreadCleanup(void *ptr) +extern "C" void wxPthreadCleanup(void *ptr) { - wxThread *thread = (wxThread *) ptr; + wxThreadInternal::Cleanup((wxThread *)ptr); +} +void wxThreadInternal::Cleanup(wxThread *thread) +{ { wxCriticalSectionLocker lock(thread->m_critsect); if ( thread->m_internal->GetState() == STATE_EXITED ) @@ -1284,7 +1294,7 @@ wxThreadError wxThread::Kill() if ( m_isDetached ) { // if we use cleanup function, this will be done from - // PthreadCleanup() + // wxPthreadCleanup() #if !HAVE_THREAD_CLEANUP_FUNCTIONS ScheduleThreadForDeletion(); diff --git a/src/unix/utilsunx.cpp b/src/unix/utilsunx.cpp index 8247bb6f9f..6fdbc765eb 100644 --- a/src/unix/utilsunx.cpp +++ b/src/unix/utilsunx.cpp @@ -1093,7 +1093,7 @@ bool wxSetEnv(const wxString& variable, const wxChar *value) #include -static void wxFatalSignalHandler(wxTYPE_SA_HANDLER) +extern "C" void wxFatalSignalHandler(wxTYPE_SA_HANDLER) { if ( wxTheApp ) { -- 2.45.2