Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

porting linux 32 bit app to 64 bit?

Tags:

c++

c

linux

64-bit

i'm about to port very large scale application to 64 Bits, i've noticed in that in the web there some articles which shows many pitfalls of this porting , i wondered if there is any tool which can assist in porting to 64 bit , meaning finding the places in code that needs to be changed.... maybe the gcc with warnnings enabled... is it good enough ? is there anything better ?

EDIT: Guys i am searching for a tool if any that might be a complete to the compiler, i know GCC can asist , but i doubt it will find all un portable problems that
will be discovered in run-time....maybe static code analysis tool that emphasize porting to 64 bits ?

thanks

like image 567
Robocide Avatar asked Aug 24 '10 15:08

Robocide


2 Answers

Here's a guide. Another one

Size of some data types are different in 32-bit and 64-bit OS, so check for place where the code is assuming the size of data types. eg If you were casting a pointer to an int, that won't work in 64bit. This should fix most of the issues.

If your app uses third-party libraries, make sure those work in 64-bit too.

like image 175
David Avatar answered Sep 29 '22 20:09

David


A good tool is called grep ;-) do

grep -nH -e '\<int\>\|\<short\>\|\<long\>' *

and replace all bare uses of these basic integer types by the proper one:

  • array indices should be size_t
  • pointer casts should be uintptr_t
  • pointer differences should be prtdiff_t
  • types with an assumption of width N should be uintN_t

and so on, I probably forgot some. Then gcc with all warnings on will tell you. You could also use clang as a compiler it gives even more diagnostics.

like image 38
Jens Gustedt Avatar answered Sep 29 '22 20:09

Jens Gustedt