From: Cary R. <cy...@ya...> - 2008-02-07 00:29:52
|
--- Larry Doolittle <ldo...@re...> wrote: > struct {bool *flag, const char *name} debug_entry; > struct debug_entry debug_flag_table[]={ > #define ENTRY(x) { &debug_##x, #x} > ENTRY(scopes), > ENTRY(eval_tree), > ENTRY(elaborate), > ENTRY(synth2) > #undef ENTRY > }; If you use a name that describes what is actually going on I think this is fine and can make it easier to understand what is going on. I would make the above DEFINE_ENTRY. Also since you go to the trouble to undef the macro why not also check that it is not already in use before you define it? This would prevent the accidental redefinition of a macro that could cause problems later in the code. I would also suggest adding some extra space to make it more clear where the macro definition and the use starts and add a single line comment describing what the macro does "/* ENTRY(scopes) produces { &debug_scopes, scopes} */". The comment should help with the opacity. To me it's all about making the intent of the code clearer. If a macro does that I say go for it. Cary ____________________________________________________________________________________ Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs |