[asterisk-dev] 0006889: [patch] Convert ast_verbose into macros

casper at casper.org.ua casper at casper.org.ua
Wed Apr 5 14:40:56 MST 2006


> Why is that else in there?  Doesn't that do the opposite?

Now it is:

#define AST_VERBOSE(level, args, ...) \
        if (option_verbose < level) ; else \
                ast_verbose(args "\n", ## __VA_ARGS__);

#define AST_VERBOSE_IF(level, cond, args, ...) \
        if ((option_verbose < level) || !(cond)) ; else \
                ast_verbose(args "\n", ## __VA_ARGS__);

#define AST_VERBOSE_RAW(level, args, ...) \
        if (option_verbose < level) ; else \
                ast_verbose(args, ## __VA_ARGS__);

#define AST_VERBOSE_RAW_IF(level, cond, args, ...) \
        if ((option_verbose < level) || !(cond)) ; else \
                ast_verbose(args, ## __VA_ARGS__);

That else is to avoid unexpected behavior after pre-processor expantions.

> this actually makes the code more error-prone, not less.

I can't agree. This can't make the code _more_ error-prone.
Can you give us a live example?..

Such macros make the code more readable with less identation.



More information about the asterisk-dev mailing list