Orphaned Response

karl at haddock karl at haddock
Wed Sep 17 09:20:00 AEST 1986


hadron!jsdy (Joe Yao) writes:
>In article <1761 at mmintl.UUCP> franka at mmintl.UUCP (Frank Adams) writes:
>>[haddock!karl (Karl Heuer) writes:]
>>>For another, the types might be
>>>unknown, if they are arguments in a macro; in this case I would want the
>>>macro to work on void as well as valued expressions.
>>This case is not covered by my suggestion.  I find it hard to imagine doing
>>it, however.
>When would one try to pass a void "value" to anything, whether or
>not it is a macro?  (I agree, that is  v e r y  hard to imagine!)

Your comment "whether or not it is a macro" suggests that you are assuming
the macro has function semantics, in which case it would not be useful to
hand it a void expression.  But not all macros have this property; consider
    #define new(T) ((T *)malloc(sizeof(T)))
which expects a type rather than an expression.

What I was thinking of (I don't have a specific instance) was a macro whose
return value has the same type as its arguments -- like generic MIN and MAX.
To concoct something that would accept void arguments, you could write
    #define foo(e1,e2) (SOMETHING ? (SOMETHING,(e1)) : (SOMETHING,(e2)))
I suppose.  Of course, the user must be aware that this is a macro, and that
its value is void when its arguments are.  In any case, I agree that it's
not all that likely, but it's not inconceivable.

Karl W. Z. Heuer (ima!haddock!karl; karl at haddock.isc.com), The Walking Lint



More information about the Comp.lang.c mailing list