DO NOT REPLY TO THIS MESSAGE. INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.
[STR New]
Link: http://www.fltk.org/str.php?L2878
Version: 1.3-current
I compiled FLTK for MSWindows 7 64-bit using the MinGW 64 bit compiler
(gcc 4.7.0) and found that there are 3 warnings for each source
file plus a few more for those that include FL/Fl_Menu_Item.H.
They come from cast operations between the long and void* types
that differ in length on the 64-bit Windows7 platform.
I believe the correct solution for that is to replace
void* user_data_;
by
union {
void* user_data_;
long long_value_;
};
in the declaration of the Fl_Widget class, and to use long_value_
instead of user_data_ wherever a long quantity is handled.
The attached file contains a patch with this change, protected
by #if FLTK_ABI_VERSION >= 10302, although I think the change
does not modify the class layout on real platforms.
Could another developer test this change with Microsoft's
64-bit compiler, and report what happens?
Link: http://www.fltk.org/str.php?L2878
Version: 1.3-currentIndex: Fl_Menu_Item.H
===================================================================
--- Fl_Menu_Item.H (revision 9572)
+++ Fl_Menu_Item.H (working copy)
@@ -110,7 +110,14 @@
const char *text; ///< menu item text, returned by label()
int shortcut_; ///< menu item shortcut
Fl_Callback *callback_; ///< menu item callback
+#if FLTK_ABI_VERSION >= 10302
+ union {
+ void *user_data_; ///< menu item user_data for the menu's callback
+ long long_value_; ///< same menu item field seen as a long quantity
+ };
+#else
void *user_data_; ///< menu item user_data for the menu's callback
+#endif
int flags; ///< menu item flags like FL_MENU_TOGGLE,
FL_MENU_RADIO
uchar labeltype_; ///< how the menu item text looks like
Fl_Font labelfont_; ///< which font for this menu item text
@@ -240,7 +247,14 @@
for the menu item's callback function.
\see Fl_Callback_p Fl_MenuItem::callback() const
*/
- void callback(Fl_Callback1*c, long p=0) {callback_=(Fl_Callback*)c;
user_data_=(void*)p;}
+ void callback(Fl_Callback1*c, long p=0) {
+ callback_=(Fl_Callback*)c;
+#if FLTK_ABI_VERSION >= 10302
+ long_value_ = p;
+#else
+ user_data_=(void*)p;
+#endif
+ }
/**
Gets the user_data() argument that is sent to the callback function.
@@ -256,7 +270,13 @@
argument. This method casts the stored userdata() argument to long
and returns it as a \e long value.
*/
- long argument() const {return (long)(fl_intptr_t)user_data_;}
+ long argument() const {
+#if FLTK_ABI_VERSION >= 10302
+ return long_value_;
+#else
+ return (long)(fl_intptr_t)user_data_;
+#endif
+ }
/**
Sets the user_data() argument that is sent to the callback function.
For convenience you can also define the callback as taking a long
@@ -264,7 +284,13 @@
and stores it in the menu item's userdata() member.
This may not be portable to some machines.
*/
- void argument(long v) {user_data_ = (void*)v;}
+ void argument(long v) {
+#if FLTK_ABI_VERSION >= 10302
+ long_value_ = v;
+#else
+ user_data_ = (void*)v;
+#endif
+ }
/** Gets what key combination shortcut will trigger the menu item. */
int shortcut() const {return shortcut_;}
@@ -388,7 +414,13 @@
the callback.
You must first check that callback() is non-zero before calling this.
*/
- void do_callback(Fl_Widget* o,long arg) const {callback_(o, (void*)arg);}
+ void do_callback(Fl_Widget* o,long arg) const {
+#if FLTK_ABI_VERSION >= 10302
+ ((Fl_Callback1*)callback_)(o, arg);
+#else
+ callback_(o, (void*)arg);
+#endif
+ }
// back-compatibility, do not use:
Index: Fl_Widget.H
===================================================================
--- Fl_Widget.H (revision 9572)
+++ Fl_Widget.H (working copy)
@@ -102,7 +102,14 @@
Fl_Group* parent_;
Fl_Callback* callback_;
+#if FLTK_ABI_VERSION >= 10302
+ union {
+ void* user_data_;
+ long long_value_;
+ };
+#else
void* user_data_;
+#endif
int x_,y_,w_,h_;
Fl_Label label_;
unsigned int flags_;
@@ -572,7 +579,14 @@
\param[in] cb new callback
\param[in] p user data
*/
- void callback(Fl_Callback1*cb, long p=0) {callback_=(Fl_Callback*)cb;
user_data_=(void*)p;}
+ void callback(Fl_Callback1*cb, long p=0) {
+ callback_=(Fl_Callback*)cb;
+#if FLTK_ABI_VERSION >= 10302
+ long_value_=p;
+#else
+ user_data_ = (void*)p;
+#endif
+ }
/** Gets the user data for this widget.
Gets the current user data (void *) argument that is passed to the
callback function.
@@ -588,13 +602,25 @@
/** Gets the current user data (long) argument that is passed to the
callback function.
*/
- long argument() const {return (long)(fl_intptr_t)user_data_;}
+ long argument() const {
+#if FLTK_ABI_VERSION >= 10302
+ return long_value_;
+#else
+ return (long)(fl_intptr_t)user_data_;
+#endif
+ }
/** Sets the current user data (long) argument that is passed to the
callback function.
\todo The user data value must be implemented using \em intptr_t or
similar
to avoid 64-bit machine incompatibilities.
*/
- void argument(long v) {user_data_ = (void*)v;}
+ void argument(long v) {
+#if FLTK_ABI_VERSION >= 10302
+ long_value_ = v;
+#else
+ user_data_ = (void*)v;
+#endif
+ }
/** Returns the conditions under which the callback is called.
_______________________________________________
fltk-bugs mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-bugs