From -2050831963813440826
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,bc2d9b2f726f122d
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 1994-06-26 08:59:43 PST
Path: bga.com!news.sprintlink.net!news.clark.net!news.clark.net!not-for-mail
From: thutt@clark.net (Taylor Hutt)
Newsgroups: comp.std.c++
Subject: Re: #if sizeof( int ) == 2
Date: 26 Jun 1994 11:59:55 -0400
Organization: Society for People Who Believe All Shampoos are the Same
Lines: 17
Message-ID: <2uk8lr$hkg@explorer.clark.net>
References: <BWH.94Jun24202306@kato.prl.ufl.edu>
NNTP-Posting-Host: clark.net
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit

In article <BWH.94Jun24202306@kato.prl.ufl.edu>,
Brian Hook <bwh@kato.prl.ufl.edu> wrote:
>Also, what is the rationale that a sizeof( variable ) can't be used?  This
>is a major issue with cross platform portability, IMO.  I would assume that
>a sizeof( variable ) would be a constant expression, unless the implicit
>promotion of ints to long ints causes problems in the evaluation.

One reason for not allowing it is cross compilation. The preprocessor for 
your cross compiler can remain the same, and only the code generator need 
change. 

>Is there another approach that can be used to basically effect the same
>results?


At runtime, you can: assert(sizeof(int) == 2);
This will get caught immediately.


