Can I convert my Windows based FLTK application to 64bit application?

514 views
Skip to first unread message

Furqan Ullah

unread,
Sep 24, 2013, 1:44:40 AM9/24/13
to fltkg...@googlegroups.com
In 3D points or mesh processing (millions of triangles), a big memory require to be allocated, that is not possible in 32bit applications. So, finally, I am planing to convert my 32bit application into 64bit.
Now my question is, can I convert FLTK application into 64bit ? If yes, then what things do I need to consider?
This would be my first application for 64bit Windows, all others works fine on 32bit Windows.

My programming plateform is, FLTK 1.3.2, Visual Studio 2010 C++, Windows XP or 7.

Thanks.

Furqan Ullah

unread,
Sep 24, 2013, 1:49:38 AM9/24/13
to fltkg...@googlegroups.com
What are the important things that I should consider during conversion from 32bit to 64bit.

For example int, long will not work for 64bit. and float should be double. etc. ?



Michael Baeuerle

unread,
Sep 24, 2013, 4:08:00 AM9/24/13
to fltkg...@googlegroups.com
Furqan Ullah wrote:
>
> What are the important things that I should consider during
> conversion from 32bit to 64bit.

FLTK should simply work out-of-the-box on both variants.

> For example int, long will not work for 64bit. and float
> should be double. etc. ?

Even for your own code it is not necessary to change data types if you
have used them correctly. The traditional C/C++ data types are always
"at least" in size. In other words you should not expect a fixed size of
bits the compiler will use either on 32bit and 64bit systems. It is
defined:
- short int : at least 16bit
- int : at least 16bit
- long int : at least 32bit
- long long int: at least 64bit
Similar for floating point. You should not expect a defined, fixed
precision for float and double.

If you need fixed size integers, since C99 there are data types like
int32_t (fixed width 32bit integer). They should also be usable for C++
too via <cstdint> and <cinttypes> with recent compilers.


Regards,

Micha

Greg Ercolano

unread,
Sep 24, 2013, 4:29:51 AM9/24/13
to fltkg...@googlegroups.com
Just be sure to compile /both/ your app /and/ any libraries you use
(including FLTK) with the same 64bit compiler.

Beyond that, be aware of potential size differences of built in
data types. For example, pointers will be 8 bytes instead of 4 bytes.

Do some tests compiling simple programs such as the following, comparing
the 32bit vs 64bit compiler results:

--- snip
#include <stdio.h>
int main() {
printf("sizeof(int)=%d\n", sizeof(int));
printf("sizeof(long)=%d\n", sizeof(long));
printf("sizeof(float)=%d\n", sizeof(float));
printf("sizeof(void*)=%d\n", sizeof(void*));
// ..add more here..
return(0);
}
--- snip

Sometimes you'll be surprised at the results.

When working with functions that do binary manipulations of data,
be mindful when manipulating data in a binary manner, such as when
using functions like fread()/fwrite()/memset()/memcpy() which are often
places to find 32bit vs 64bit issues.

Also, be aware when casting data to different data types, as there
may be precision loss issues. Example: in FLTK we use void* for passing
"user data" through callbacks. Passing an int data type through a void*
may be a problem when trying to cast the void* back to an int; the compiler
may complain of loss of precision, as sizeof(void*)=8 being possibly larger
than sizeof(int) which may still be 4.

Things you typically /won't/ have to worry about are strings and
char arrays.. most image data is treated as char arrays, and will
typically be unaffected by 32bit vs 64bit compiles.

There's other things to look out for, but this should get you started.
Often it's not as bad as you'd think.

MacArthur, Ian (Selex ES, UK)

unread,
Sep 24, 2013, 4:52:14 AM9/24/13
to fltkg...@googlegroups.com
> What are the important things that I should consider during conversion from
> 32bit to 64bit.

FLTK should work fine - you will need to build a 64-bit version of fltk of course, but that is straightforward.

> For example int, long will not work for 64bit. and float should be double.
> etc. ?

standard types,; int, long, float, double will all work just fine and should not generally need changed.

There is no reason to change from float to double unless you need the extra resolution.

On Windows, note that MS decided not to change the sizes of the stock types, so *under Windows 64 bit* an int and a long are both still 32-bit types.

On other 64 bit hosts, an int is still 32-bit but a long becomes 64-bit.

You probably want to google about on this topic, there's a lot of good information out there.

The one that you really have to watch for is passing pointers via integral types; lots of code assumes a long is big enough to hold a pointer on all platforms, but of course under Win64 that is not true.

Fltk provides typedef's for handling this (i.e. an integral type that is big enough to hold a pointer and v.v) that you can use; fl_intptr_t and fl_uintptr_t.

For my own part, I have enthusiastically embraced the use of C99 stdint types everywhere in my code. This annoys purists who will tell you that the C++ compilers do not support C99 types, but in practice they all do these days...

So, that’s int32_t, int64_t, etc...




Selex ES Ltd
Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS14 3EL
A company registered in England & Wales. Company no. 02426132
********************************************************************
This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.
********************************************************************

Reply all
Reply to author
Forward
0 new messages