On 04/03/13 08:44, marty moore wrote:
> I notice that old examples used
> int i = (int)v;
> but that won't work with gcc-4.4.5
Right -- probably a "precision loss" error during the void* -> int,
since sizeof(void*)==8 and sizeof(int)==4.
I think the best approach (in 1.3.x) is to use the new fl_intptr_t, e.g.
int i = fl_intptr_t(v);
Or, you could just use a long instead of an int, but that might cause
trouble on non-64bit builds.. which is I think what fl_intptr_t tries
to solve. (See the definition in FL/Fl_Widget.H)
There is a "long Fl_Widget::argument()" method which would let you do:
void mycallback(widget* w, void* v) {
long li = w->argument();
[..]
..but again, I think you'd loose on a 32bit build when doing the
long->void* cast.
Which is why I think the fl_intptr_t is probably the best way to go.
While dicking around, of interest I found this also seems to evade
the precision loss error, not completely sure why:
void foo(Fl_Widget *w, void *v) {
int i = (int)(long)(v);
[..]
> Should this be covered in a tutorial?
Probably -- I don't think fl_intptr_t is even documented yet
(it has a 'todo' signifier), but it's defined in Fl_Widget.H
and used in some of the examples, like test/tree.cxx.
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk