Re: how to tell 64 vs 32 bit architecture ?

From: Giorgos Keramidas <keramida_at_ceid.upatras.gr>
Date: Fri, 7 Sep 2007 15:49:39 +0300
On 2007-09-07 05:03, Luigi Rizzo <rizzo_at_icir.org> wrote:
>On Fri, Sep 07, 2007 at 02:50:21PM +0300, Giorgos Keramidas wrote:
>>> i am actually looking at pointer sizes, as i need to do some pointer
>>> manipulation going through intptr_t, and need to know that in the
>>> preprocessor because some constants need to be 32 or 64 bit depending
>>> on that, and are not trivial (i.e. not 0, 1 or something i can build
>>> with size-agnostic expressions)
>>
>> An intptr_t can safely hold any void pointer value [..a.]
>> What sort of manipulation?  Can this sort of manipulation be written in
>> a way that uses sizeof(intptr_t) instead of 4, 8, or preprocessor magic?
>
> i need to do this:
>
> #ifdef BUILT_FOR_64BIT_POINTERS
> #define	MY_MAGIC	0xdeadbeefd00de123	/* 64 bit */
> #else
> #define	MY_MAGIC	0xdeadbeef		/* 32 bit */
>
> If you know of a way to implement this without preprocessor
> magic, i am all ears. If the values were simpler (eg all ones or so)
> i could have used ~((unitptr_t)0) but this is not the case here

You essentially want sizeof() at the preprocessor context.   I don't
think this is possible to write portably without preprocessor magic.
Received on Fri Sep 07 2007 - 10:50:11 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:17 UTC