views:

73

answers:

2

Hi, I am working on Linux 64 bit porting and we used a lots of long variable in our code. Now on Linux 64 long is 64 bit. We are facing problem in the bits manipulation code. I heard there are options LLP64(long as 32) and ILP64(long as 64). But I don’t know the compiler option for it(g++). I have few more doubts, If I compile with option LLP64 then the executable will be native 64 bit or not?
With this option, can I include the 64 bit third libraries or not?

+4  A: 

gcc doesn't let you choose LLP64 , atleast not on linux targets. Even if it did, you wouldn't be ABI compatible with other libraries (including libc).

You'll have to either

  • fix the code to deal with longs being 32 or 64 bit,
  • change the code to use ints (or better int32_t).
  • change the code to use long long (or better int64_t)
  • compile the application as 32 bit (which will run fine on a 64 bit machine provided the 32 bit libraries it uses are present)
nos
Worth to mention that the types int32_t and int64_t come from the [stdint.h](http://www.opengroup.org/onlinepubs/000095399/basedefs/stdint.h.html). Many whyever do not know about it.
Dummy00001
A: 

It concerns to Windows, but patterns of 64-bit errors will be useful also to developers for Linux:

Lessons on development of 64-bit C/C++ applications.

Andrey Karpov