> Strictly conformant to the above would therefore be:
> 
> #define       dirfd(dp)       ((dp) ? (dp)->dd_fd : -1)
> 
> You'd still crash if you pass an invalid pointer,
> though.

Regardless of one's opinion on checks for  NULL args, as a macro,
that's bad, with multiple references to the arg on the right hand side
(think side-effects if someone has an array of DIR * and passes
*dpp++).  And if the standard allows a macro as well as a function,
and of course both should behave the same, I suppose that implies
at the very least that anyone wanting the performance of a macro
in addition to a function couldn't possibly be interested in optional
argument validation.

Which leads to the next question: should we provide a macro as well
as a function?
 
 
This message posted from opensolaris.org
_______________________________________________
opensolaris-discuss mailing list
[email protected]

Reply via email to