On Thu, Sep 23, 2010 at 04:12:15AM -0700, Albrecht Schlosser wrote:
> On 23.09.2010, at 10:37, MacArthur, Ian (SELEX GALILEO, UK) wrote:
> >
> >>    This ugly hack might sufficiently fool the compiler, at least
> >>    for another 10 years, LOL:
> >>
> >>            long argument() const {return *((long*)user_data_);}
> >>
> >>    I'm not sure what the 'right' solution is, or if there even
> >>    is one for what's being done here.

Sorry for the late reply and thanks for your help!

I added this hack to two files in the Fl directory (the released
tarball as well as the svn version (1.3) using the following 2 patches:

*** Fl_Widget.H.old     Tue Sep 28 18:01:34 2010
--- Fl_Widget.H Tue Sep 28 17:56:18 2010
***************
*** 596,602 ****
  
    /** Gets the current user data (long) argument that is passed to the 
callback function.
     */
!   long argument() const {return (long)user_data_;}
  
    /** Sets the current user data (long) argument that is passed to the 
callback function.
        \todo The user data value must be implemented using a \em union to 
avoid 
--- 596,602 ----
  
    /** Gets the current user data (long) argument that is passed to the 
callback function.
     */
!   long argument() const {return *((long*)user_data_);}
  
    /** Sets the current user data (long) argument that is passed to the 
callback function.
        \todo The user data value must be implemented using a \em union to 
avoid 

... and ...

*** Fl_Menu_Item.H.old  Tue Sep 28 18:02:00 2010
--- Fl_Menu_Item.H      Tue Sep 28 17:59:43 2010
***************
*** 241,247 ****
      and casting the long to a void* and may not be
      portable to some machines.
    */
!   long argument() const {return (long)user_data_;}
    /**
      For convenience you can also define the callback as taking a long
      argument.  This is implemented by casting this to a Fl_Callback
--- 241,247 ----
      and casting the long to a void* and may not be
      portable to some machines.
    */
!   long argument() const {return *((long*)user_data_);}
    /**
      For convenience you can also define the callback as taking a long
      argument.  This is implemented by casting this to a Fl_Callback

This seems to help already, but since I am not a c++ wizzard (in fact
I have just only started programming in c++ whereas before I used
perl) I need again some help. After applying those patches to the
svn-1.3 branch, I receive this error (again "precision loss"):

=== making jpeg ===
=== making zlib ===
=== making png ===
=== making src ===
Compiling Fl_Preferences.cxx...
Fl_Preferences.cxx: In static member function 'static const char* 
Fl_Preferences::newUUID()':
Fl_Preferences.cxx:140:37: error: cast from 'time_t*' to 'unsigned int' loses 
precision
Fl_Preferences.cxx: In function 'char* decodeText(const char*)':
Fl_Preferences.cxx:669:8: warning: suggest explicit braces to avoid ambiguous 
'else'
make[1]: *** [Fl_Preferences.o] Error 1
make: *** [all] Error 1

I would be thankful for any help. 

I set up a little project on sourceforge.net, a kind of primitive
package manager for mingw, which as for now only servers to make the
steps compiling on mingw with gcc more transparent:

the fltk makefile is under pkg/fltk-1.3-svn, as well as the patches.

http://thepugproject.svn.sourceforge.net/thepugproject/

Thanks for your help. 

Gabriel 


> >
> > I wondered if we could have #define that resolves to "long long" on
> > Win64 and "long" everywhere else and "fix" it that way?
> >
> > Would that work?
> 
> I'm not sure, but I don't think so. The function returns a "long",
> and that's documented and shouldn't be changed to protect existing
> user code.
> 
> The internal user_data member is defined as "void *", and we need
> to keep this as well to be able to store real pointers.
> 
> IMHO we need a tricky cast and ISTR that someone wrote that Greg's
> approach is the "usual" way to avoid such warnings.
> 
> Looks at least as if it could solve this and maybe other similar
> issues by suppressing the warnings (or maybe even errors in some
> cases).
> 
> Albrecht
> _______________________________________________
> fltk mailing list
> [email protected]
> http://lists.easysw.com/mailman/listinfo/fltk

_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to