NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: [9.1 AMD64 gcc] How to distinguish between AMD64 and I386 from C code?



On Wed, Jan 27, 2021 at 04:07:09PM +0300, Lord Vader wrote:
> Hi!
> 
> On different linuxes with gcc 8.x and 9.x there is __WORDSIZE, that is
> either 32 or 64 depending on the architecture.

The classic test is #ifdef _LP64

You can check (assuming you are on amd64) with something like:

	cc -dM -E - < /dev/null

vs

	cc -m32 -dM -E - < /dev/null

(A similar check works elsewhere, but -m32 is machine dependend)

Martin


Home | Main Index | Thread Index | Old Index