From -2103542333308739988
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,bc2d9b2f726f122d
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 1994-06-27 10:01:30 PST
Newsgroups: comp.std.c++
Path: bga.com!news.sprintlink.net!hookup!yeshua.marcam.com!MathWorks.Com!europa.eng.gtefsd.com!newsxfer.itd.umich.edu!gatech!swrinde!news.uh.edu!uuneo.neosoft.com!jabberwock!daniels
From: daniels@biles.com (Brad Daniels)
Subject: Re: #if sizeof( int ) == 2
References: <BWH.94Jun24202306@kato.prl.ufl.edu>
Organization: Biles and Associates
Date: Mon, 27 Jun 1994 15:12:52 GMT
Message-ID: <Cs2A9I.7nI@biles.com>
Lines: 31

In article <BWH.94Jun24202306@kato.prl.ufl.edu>,
Brian Hook <bwh@kato.prl.ufl.edu> wrote:
...
>#if sizeof( int ) == 2
>// assume 16-bit architecture
>#endif
...

One other way to test this is to check the value of UINT_MAX for being
greater that 0xffff.  Another approach I like to use is:

#if ((0xffff+1) < 0xffff)
// 16 bits
#else
#if ((0xffffffff+1) < 0xffffffff)
// 32 bits
#else
// 64 bits
#endif
#endif

The one danger with this approach is that the preprocessor might interpret
things differently than the compiler.  I mainly use this approach for 32/64
bit checks.

- Brad
----------------------------------------------------------------------
+ Brad Daniels                  | Freedom isn't free, but here at    +
+ Biles and Associates          | Joe's Bail Bonds and Used Cars, we +
+ These are my views, not B&A's | can get it for ya dirt cheap!      +
----------------------------------------------------------------------


