[ofa-general] Re: [PATCH] libibmad/rpc.c: Handle redirection status

Sasha Khapyorsky sashak at voltaire.com
Wed Mar 11 02:37:07 PDT 2009


On 16:40 Tue 10 Mar     , Hal Rosenstock wrote:
> >
> > IOW no need to put { } braces around single expression.
> 
> Compiler complains about ambiguous else without this.

I believe. This is because:

#define ERRS if (iberrs || ibdebug) IBWARN

So construction like:

	if (cond)
		ERRS("something");
	else
		...

, after preprocessor it becomes:

	if (cond)
		if (iberrs || ibdebug)
			IBWARN("someting");
	else
		...

, and gcc complains about ambiguous else.

To avoid such sort of things I recommended in previous email to wrap
ERRS() macro with do {} while (0):

#define ERRS(fmt, ...) do { \
		if (iberrs || ibdebug) \
			IBWARN(fmt, ## __VA_ARGS__); \
	} while (0)

Sasha



More information about the general mailing list