C Compiler bug (and fix for a different one)

Andrew Koenig ark at alice.UucP
Wed Aug 6 23:07:03 AEST 1986


>	Consider the case where you're writing a really complex #define macro,
>and you decide that you'd like some sort of IF statement in it,
>(take a look at getchar()).  Can't you see a case where you might want to
>call a void function, and then set the value of the #define macro to be
>a side effect of the function?  Sort of like
>#define foo(c) buffer_empty?fill_buff(),first_char_in_buf:first_char_in_buf

No problem using a void as the LHS of a comma operator, just as
there's no problem using a void before a semicolon.

Of course, you'd better parenthesize:

	#define foo(c) (empty?(fill(),first):first)

Moreover, fill() probably returns a value you don't want to ignore,
so maybe you should write it to return either the value of first or
an error code.  You can then write

	(empty?fill():first)

which avoids the void issue altogether.



More information about the Comp.lang.c mailing list