Subject: Re: [boost] Detection of 64bit using macro
From: Andrey Semashev (andrey.semashev_at_[hidden])
Date: 2010-08-15 06:47:02
On 08/14/2010 04:05 PM, John Maddock wrote:
>>> the question might be not directly related to boost. But i just want to
>>> be sure that i am not reventing the wheel.
>>> I am searching for a macro that is able to detect that a system is 32bit
>>> or 64bit no matter what compiler is used.
>>> Is there something similar already implemented in boost?
>> There is no standard macro to detect this, so every solution will be
>> platform-specific. For instance, I think, GCC defines some macro that
>> has value of sizeof(void*). On platforms with uintptr_t you can test
>> for UINTPTR_MAX macro value. On linux there is __WORDSIZE macro that
>> has value of number of bits in the native integer type (that is, 32 or
> You also need to specifiy what you mean by "64 bit", do you mean 64-bit
> pointers, or 64-bit integers or both, or something else, as these can
> all vary independently of each other.
It's not that I disagree with you, but usually platforms are referred to
as 64-bit when a program is able to address 64 bit address range, which
means that the pointer type has to be at least 64-bit. The support for
64-bit integers is much less connected to the platform architecture.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk