简体   繁体   English

Linux 64位移植问题

[英]Linux 64 bit porting issue

I am working on Linux 64 bit porting and we used a lots of long variable in our code. 我正在Linux 64位移植上,我们在代码中使用了很多long变量。 Now on Linux 64 long is 64 bit. 现在在Linux 64上,long是64位。 We are facing problem in the bits manipulation code. 我们在位操作代码中面临问题。 I heard there are options LLP64(long as 32) and ILP64(long as 64). 我听说有选项LLP64(长为32)和ILP64(长为64)。 But I don't know the compiler option for it(g++). 但是我不知道它的编译器选项(g ++)。 I have few more doubts, If I compile with option LLP64 then the executable will be native 64 bit or not? 我还有更多的疑问,如果我使用选项LLP64进行编译,那么可执行文件是否将是本机64位?
With this option, can I include the 64 bit third libraries or not? 使用此选项,是否可以包含64位的第三库?

gcc doesn't let you choose LLP64 , atleast not on linux targets. gcc不允许您选择LLP64,至少不能在linux目标上使用。 Even if it did, you wouldn't be ABI compatible with other libraries (including libc). 即使这样做,您也不会与其他库(包括libc)兼容。

You'll have to either 你要么必须

  • fix the code to deal with longs being 32 or 64 bit, 修复代码以处理32或64位的long,
  • change the code to use ints (or better int32_t). 更改代码以使用int(或更好的int32_t)。
  • change the code to use long long (or better int64_t) 更改代码以使用long long(或更好的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) 将应用程序编译为32位(如果存在使用的32位库,则可以在64位计算机上正常运行)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM