tags:

views:

164

answers:

3

Hello,

I am developing an application that will run on 64 bit computers.

However, we are using a library that has 32 bit integers that we cannot change. And we will need to compile and run on a 64 bit computer.

What would the implications be when the application is running? Is there any work around?

Many thanks for any advice,

+2  A: 

I'm assuming you mean x86 and x86_64 here when you talk about 64-bit.

int is 32-bit on both of these architectures.

The only problem you tend to run into are when you assume:

  • sizeof(void*) == sizeof(int)
  • sizeof(int) == sizeof(long)
  • The size of long or long long is the same size.

Otherwise you'll be fine.

Mike McQuaid
sepp2k
A bit pedantic I feel considering any computer anyone who is asking this question on will have a 32-bit integer and he already mentioned it. Corrected my answer anyway.
Mike McQuaid
A: 

Your best bet would be to write a wrapper around the library that hides any differences.

It's not clear from your email if the library in question in a 64bit library that happens to use 32bit integers or a 32bit library. Either way, a wrapper around the library is probably the best way to go

Sean
+1  A: 

Do you have the source for the library? If so, and you recompile it, you might get away with it (as long as the writers of the library didn't make any assumptions that are broken when compiling for x86-64). Test hard, and test long.

If you don't have the source (you just have an i386 compiled binary), the linker won't even let you link x86-64 code to it. The ABIs just aren't compatible.

In the second case, you'll have to create a separate 32-bit helper/wrapper process that links to the 32-bit library, and takes requests to call the library from the 64-bit process through an IPC mechanism (returning the results). You can create wrapper functions on the 64-bit side around the IPC so that it looks like normal calls to the library. Your 64-bit process will have to kick off the 32-bit helper process when it starts up (and make sure the helper process knows to exit when the parent process disappears).

caf