Boost logo

Boost :

Subject: Re: [boost] Detection of 64bit using macro
From: John Maddock (boost.regex_at_[hidden])
Date: 2010-08-14 08:05:19


>> 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 64).

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.

John.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk