How does gcc tell if a 32-bit or 64-bit executable is generated by default?
In my 64-bit
Solaris, my gcc generates 32-bit executables by default (generating 64-bit executables requires the “-m64” compilation option). In my 64-bit Linux, my gcc generates a 64-bit executable by default. I tried to find the reason in gcc website, but unfortunately there are too many related options (–with-arch、–with-cpu、–with-abi, etc.). From the docs, I don’t see which one can determine whether to generate a 32-bit or 64-bit executable.
Can someone give some advice on this?
It depends on
how the compiler is installed, which really depends on the distro and possible installation options. If there are any doubts and need for certainty, simply include the -m option; It doesn’t hurt to use -m32 when the default is 32-bit, as does -m64 when the default is 64-bit.