[Top][All Lists]
[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.
- intro, xystrus, 2002/03/12
- Re: intro, Sergey Poznyakoff, 2002/03/12
- Re: intro,
Alain Magloire <=
- Re: intro, Alain Magloire, 2002/03/13
- Message not available
- Re: intro, xystrus, 2002/03/13
- Message not available
- mailbox (was Re: intro), xystrus, 2002/03/13
- Re: mailbox (was Re: intro), Alain Magloire, 2002/03/13
- Re: mailbox (was Re: intro), Jeff Bailey, 2002/03/13
- Re: mailbox (was Re: intro), Alain Magloire, 2002/03/13
- Re: mailbox (was Re: intro), Sergey Poznyakoff, 2002/03/13
- Re: mailbox (was Re: intro), Alain Magloire, 2002/03/13