bug-mailutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: intro


From: Alain Magloire
Subject: Re: intro
Date: Tue, 12 Mar 2002 11:12:56 -0500 (EST)

> 
> > For example, here's a snippet of code from imap4d.h that defines
> > macros for the various IMAP states:
> [..snip..]
> >  #define STATE_LOGOUT    (1 << 3)
> >
> > I'm curious why these were defined this way...  It strikes me as
> > a little inefficient.  Each time these are used, they are replaced
> > with a bit-shift calculation
> 
> No, they are not. The compiler computes all immediate constants
> on early stages of parse tree handling. It was described in K&R,
> though I don't have the book right at hand to cite it :^)

Yes, for ansi C. A constant expression is evaluated at compilation
time rather then runtime.
It is also a question of style, and make it obvious that the macro
will be use bitwise, and avoid mistakes:
#define STATE_SEL    0x3 // No!

Both are fine with me.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]