tags:

views:

96

answers:

3

I am trying to port 32bit code to 64bit linux machine. Are there any compiler flags for 64bit posrting warning on Linux.

There are +w2 -m64 flags for SUN. Could anyone give me information for flags similar to this one?

Thank you in advance,

+2  A: 

hope that helps 20 issues of porting C++ code on the 64-bit platform

lsalamon
A: 

This is not exactly the answer you are looking for, but you could try replace as many int as possible with int32_t in a first porting phase. Also look at the other answer. (No I can not comment, seems I have too little rep...)

Amigable Clark Kant
On AMD64 linux, int == int32_t. long == int64_t. Your suggestion is to change int to unsigned int, which if anything will introduce bugs.
Peter Cordes
Good call! I meant int32_t.
Amigable Clark Kant
A: 

Try gcc -Wall -Wconversion -Wpointer-arith -Wtype-limits -Wcast-qual

Actually, read the gcc man page, there are a ton of warnings, and some of them may be helpful only if your code doesn't produce a flood of them for things you know aren't actually a problem. -Wall, -pedantic, and -Wextra are meta-flags that turn on a bunch of warnings. -Wall includes many of the important ones that will occur when you try a 64bit build of code that does bad things.

-Werror (turn warnings into errors) might be useful to avoid having to make clean after fixing some but not all errors.

Peter Cordes