Calling multiple functions in a macro.

Dave Hammond daveh at marob.MASA.COM
Tue Nov 1 01:29:10 AEST 1988


In attempting to construct a macro which calls several functions,
but can be used as a single statement (i.e. without braces in an if/else
construct), I can see 2 possible alternatives:

1.
#define FOO()	do { foo1(); foo2(); foo3() foo4(); } while(0)

2.
#define FOO()	foo1(), foo2(), foo3(), foo4()

The first adds quite a bit of code to the program and makes lint
complain about constants in conditional text.

The second compiles, executes and lints correctly (on Xenix), but
is it portable to string function calls in this manner?

Dave Hammond
  UUCP: ...!uunet!masa.com!{marob,dsix2}!daveh
DOMAIN: daveh at marob.masa.com
----------------------------------------------------------------------------



More information about the Comp.lang.c mailing list