[TUHS] When was #if introduced in C? (was: Re: Mac OS X is Unix)

Michael Kjörling michael at kjorling.se
Wed Jan 4 07:33:31 AEST 2017


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.semichael at kjorling.se
                 “People who think they know everything really annoy
                 those of us who know we don’t.” (Bjarne Stroustrup)


More information about the TUHS mailing list