From mboxrd@z Thu Jan 1 00:00:00 1970 From: michael@kjorling.se (Michael =?utf-8?B?S2rDtnJsaW5n?=) Date: Tue, 3 Jan 2017 21:33:31 +0000 Subject: [TUHS] When was #if introduced in C? (was: Re: Mac OS X is Unix) In-Reply-To: References: <201701032019.v03KJ8oq028944@tahoe.cs.Dartmouth.EDU> Message-ID: <20170103213331.GN31772@yeono.kjorling.se> On 3 Jan 2017 13:05 -0800, from charles.unix.pro at gmail.com (Charles Anthony): > I was compiling on a 32 bit int machine; the compiler flagged the '1u << > 60' as a fatal error due to the size of the shift -- on this compiler the > expression evaluator was running before the dead code remover. That was my thought too; the only way to guarantee that the code is removed before the compiler sees it is to do so through the preprocessor, thus #ifdef. Of course, #ifdef is rather limited. The #if preprocessor directive is more generic, but still significantly less versatile than the if() language keyword. Which makes me curious... Does anyone here happen to know when #if was introduced in C? I suspect #ifdef came earlier simply by virtue of being (at least to a naiive first approximation) far easier to implement, as all that would be required would be to look at the macro expansion table (already required by #define) and see if that particular name had previously been #defined, as opposed to actually evaluating an expression. -- Michael Kjörling • https://michael.kjorling.se • michael at kjorling.se “People who think they know everything really annoy those of us who know we don’t.” (Bjarne Stroustrup)