expr?(void):(void)
Jonathan Leech
jon at amdahl.UUCP
Fri Aug 1 04:18:38 AEST 1986
In article <5826 at think.COM>, sam at think.COM (Sam Kendall) writes:
> ...
> Enough cheap shots. Here is an example of using void in "?:". Suppose
> you are writing a stdio-like package, and one function has this
> specification:
>
> void PutC(Stream, char);
>
> But for efficiency you want to write PutC as a macro. So you define it
> like this:
>
> extern void _WriteBuf(Stream);
> #define PutC(s, c) (--(s)->count >= 0 ? (void) (*(s)->bufp++ = (c)) \
> : _WriteBuf(s, c))
I won't argue with the desirability of being able to do this, but
I believe your example is poorly chosen. I/O functions can always fail
and some indication of this ought to be returned to the user where
possible, even though few bother to check usage like this.
-- Jon Leech (...seismo!amdahl!jon)
UTS Products / Amdahl Corporation
__@/
More information about the Comp.lang.c
mailing list