tech-kern archive

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

Re: KNF and the C preprocessor



> Explicit enums are a little better, no?  And they do make things a
> lot more obvious when debugging.

Sometimes.  (Ab)using enums for bitmasks or other things that get
arithmetic applied to them (eg, O_EXEC, to pick a recently-discussed
example) is, IMO, broken - besides being unwarranted chumminess with
the compiler, they don't help debugging; even a debugger that can turn
64 into O_ASYNC won't be able to turn 3589 back into
O_CREAT|O_TRUNC|O_EXCL|O_WRONLY|O_NONBLOCK.

>> b) __LINE__ (etc) have the value of the use, not the definition.
> Yes, but if you use static inlines, the debugger's got both -- which
> it won't, if you use macros...

Huh?

Okay, what's the static inline version of log() here?

#define log(msg) log_(__FILE__,__LINE__,(msg))
extern void log_(const char *, int, const char *);

/~\ The ASCII                             Mouse
\ / Ribbon Campaign
 X  Against HTML                mouse%rodents-montreal.org@localhost
/ \ Email!           7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B


Home | Main Index | Thread Index | Old Index