> 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. 

OK - the warnings about explicit braces are just warnings and are being 
worked on elsewhere so we can ignore that for now.

The error comes from this line:

     unsigned int a = (unsigned int)&t; // four more bytes

And is a variation on the previous error. Here, at this point in the 
code, what we are trying to do is form a UUID on a WinXX system that 
does not have the UuidCreate() function available (probably because it 
does not have the Rpcrt4.dll available for some reason...)

So, we are looking for sources of "random" data, and what we are trying 
to do at this point is read the bottom four bytes of the *address* of a 
time_t variable that we recently created on the stack.

But this fails because on a Win64 system, the *address* of a variable is 
a 64-bit entity and we are trying to store it in an unsigned int, which 
of course is a 32-bit entity...

Worse than that, it rather looks as if I wrote that code, so it's my bad...

Well, I don't have a 64-bit windows system to test this on (and actually 
it is probably broken on any 64-bit system, it ought to be "unsigned 
long", not "unsigned int" and even that's not robust... we only get away 
with it here because this code is #ifdef'd to be Windows specific so no 
one else actually hits it.)

So, without any testing whatsoever, here's a guess; try this -

//    unsigned int a = (unsigned int)&t; // four more bytes
     union { void *pv; unsigned char a[sizeof(void*)]; } v;
     v.pv = (void *)(&t);
     // we will extract 4 more bytes from the address of t
     b[8] = v.a[0];
     b[9] = v.a[1];
     b[10] = v.a[2];
     b[11] = v.a[3];

Hopefully it is clear enough which lines I expect you to replace... 
(hint: lines 140 to 144 inclusive of Fl_Preferences.cxx)


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

Reply via email to