Sender: crough45 AT amc DOT de Message-Id: <97Jul19.150632gmt+0100.17025@internet01.amc.de> Date: Sat, 19 Jul 1997 14:11:41 +0100 From: Chris Croughton Mime-Version: 1.0 To: MCLSSAA2 AT fs2 DOT mt DOT umist DOT ac DOT uk Cc: djgpp AT delorie DOT com Subject: Re: sizeof() in #if Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Precedence: bulk Anthony Appleyard wrote: > I imagine that, if you simply wrote e.g. if(sizeof(int)==4) > and the like, that if you compile with optimization, the > compiler will detect conditions like this which can be worked > out at compile time, and not bother to compile parts of the > program which as a result are never obeyed. Indeed it will. However, that's no use for the wanted purpose, which was doing typedefs for the appropriate size. (It also depends on te optimiser not making horrible mistakes: I once lost half a function to an optimisation bug where it thought that it knew what the value in an if was but got it wrong...) Certainly doing run-time tests for sizes can be useful because in almost all cases they are optimised out, and they are often clearer than puting #if around things. > They may well come, if you boot up with a floppy in the > drive or the like. There is a computer virus called DaBoys. I didn't know that. But does it do its job with sax and violins? (It doesn't matter if I boot up with a floppy in the drive - a nice thing with a modern BIOS is being able to disable booting from floppy, and my machine is configured like that except for the rare occasions when I need to use a real boot floppy for system recovery. I recommend anyone with a modern BIOS to do that, it saves a lot of hassle.) Chris C