| [ Return to Bugs & Features | Roadmap 2.0 | Post Text | Post File | SVN ⇄ GIT ]
STR #1826
Application: | FLTK Library |
Status: | 5 - New |
Priority: | 1 - Request for Enhancement, e.g. asking for a feature |
Scope: | 2 - Specific to an operating system |
Subsystem: | Unassigned |
Summary: | fltk2-svn compiler error under x86_64-pc-mingw32 platform |
Version: | 2.0-feature |
Created By: | drangon |
Assigned To: | Unassigned |
Fix Version: | Unassigned |
Update Notification: | |
Trouble Report Files:
[ Post File ]No files
Trouble Report Comments:
[ Post Text ]
|
#1 | drangon 20:55 Nov 23, 2007 |
| fltk2-svn compiler error under x86_64-pc-mingw32 platform,
x86_64-pc-mingw32 has an ABI that long is 4 bytes, but void * is 8 bytes, so it can't convert from "void *" to long, It need to convert from "void *" to "intptr_t" then to "long", or use "intptr_t" instead of "long".
The following is a mini patch that make compile go though :
Index: src/GSave.cxx =================================================================== --- src/GSave.cxx (版本 5989) +++ src/GSave.cxx (工作副本) @@ -81,7 +81,7 @@ } GSave::~GSave() { - unsigned v = (unsigned) (unsigned long)data[3]; + unsigned v = (unsigned) (unsigned long)(intptr_t)data[3]; fl_clip_w = v >> 16; fl_clip_h = v & 0xffff; #if USE_X11 Index: fltk/Widget.h =================================================================== --- fltk/Widget.h (版本 5989) +++ fltk/Widget.h (工作副本) @@ -25,6 +25,8 @@ #include "Style.h" #include "Rectangle.h" +#include <inttypes.h> + namespace fltk { class FL_API Widget; @@ -116,7 +118,7 @@ void callback(Callback1*c, long p=0) { callback_=(Callback*)c; user_data_=(void*)p; } void* user_data() const { return user_data_; } void user_data(void* v) { user_data_ = v; } - long argument() const { return (long)user_data_; } + long argument() const { return (long)(intptr_t)user_data_; } void argument(long v) { user_data_ = (void*)v; } uchar when() const { return when_; } void when(uchar i) { when_ = i; } Index: fltk/compat/FL/Fl_Menu_Item.H =================================================================== --- fltk/compat/FL/Fl_Menu_Item.H (版本 5989) +++ fltk/compat/FL/Fl_Menu_Item.H (工作副本) @@ -91,7 +91,7 @@ unsigned labelsize() const {return labelsize_;} fltk::Callback_p callback() const {return callback_;} void* user_data() const {return user_data_;} - long argument() const {return (long)user_data_;} + long argument() const {return (long)(intptr_t)user_data_;} int shortcut() const {return shortcut_;} int submenu() const {return flags&(FL_SUBMENU|FL_SUBMENU_POINTER);} int checkbox() const {return flags&FL_MENU_TOGGLE;} [drangon@dgn64 fltk2-svn]$ LANG=C svn diff Index: src/GSave.cxx =================================================================== --- src/GSave.cxx (revision 5989) +++ src/GSave.cxx (working copy) @@ -81,7 +81,7 @@ } GSave::~GSave() { - unsigned v = (unsigned) (unsigned long)data[3]; + unsigned v = (unsigned) (unsigned long)(intptr_t)data[3]; fl_clip_w = v >> 16; fl_clip_h = v & 0xffff; #if USE_X11 Index: fltk/Widget.h =================================================================== --- fltk/Widget.h (revision 5989) +++ fltk/Widget.h (working copy) @@ -25,6 +25,8 @@ #include "Style.h" #include "Rectangle.h" +#include <inttypes.h> + namespace fltk { class FL_API Widget; @@ -116,7 +118,7 @@ void callback(Callback1*c, long p=0) { callback_=(Callback*)c; user_data_=(void*)p; } void* user_data() const { return user_data_; } void user_data(void* v) { user_data_ = v; } - long argument() const { return (long)user_data_; } + long argument() const { return (long)(intptr_t)user_data_; } void argument(long v) { user_data_ = (void*)v; } uchar when() const { return when_; } void when(uchar i) { when_ = i; } Index: fltk/compat/FL/Fl_Menu_Item.H =================================================================== --- fltk/compat/FL/Fl_Menu_Item.H (revision 5989) +++ fltk/compat/FL/Fl_Menu_Item.H (working copy) @@ -91,7 +91,7 @@ unsigned labelsize() const {return labelsize_;} fltk::Callback_p callback() const {return callback_;} void* user_data() const {return user_data_;} - long argument() const {return (long)user_data_;} + long argument() const {return (long)(intptr_t)user_data_;} int shortcut() const {return shortcut_;} int submenu() const {return flags&(FL_SUBMENU|FL_SUBMENU_POINTER);} int checkbox() const {return flags&FL_MENU_TOGGLE;} | |
|
#2 | ianmacarthur 10:01 Nov 24, 2007 |
| I assume the decision to make a long 4 bytes rather than 8 bytes was driven by a need to be compatible with M$ API - they seem to have gone for a 4-byte long on their 64-bit platforms.
However, I'm not convinced this patch is necessarily the Right Answer, as we need to consider how it will play on other platforms too... | |
|
#3 | dejan 15:13 Nov 25, 2007 |
| Hmmm, I am not sure this patch is 100% portable... | |
|
#4 | drangon 19:10 Nov 25, 2007 |
| When will it be not portable ? Some compiler does not has <inttypes.h> ? "long" does not always has the same size with "void *", and "intptr_t" is designed for this. | |
|
| inttypes.h is indeed not available with most versions of MSVC. | |
|
#6 | dejan 17:49 Nov 26, 2007 |
| Well, AFAIK, intptr_t is part of the C99 standard. I bet there are people who still use compilers who do not conform to this standard... | |
[ Return to Bugs & Features | Post Text | Post File ]
|
| |