Kevin P. Fleming wrote:
Matthew Woehlke wrote:
...but this ("typeof(&((b)[0]))") seems like it might work, assuming
that "b" is a string literal, a [const] char*, or a [const] char[].
Yes, in fact, this does seem to work:
#define S_OR(a, b) ({typeof(&((a)[0])) __x = (a); ast_strlen_zero(__x) ?
(b) : __x;})
Ah, simplification ;-).
This macro appears to work fine, compiles in all our existing usage
situations (combinations of char *, char [], const vs. non-const) and
provides the side-effect-safe evaluation of its arguments I was looking
for in the first place. Thanks!
You're welcome! (Now, if only I knew why that odd incantation is
needed... :-) )
--
Matthew
Please do not quote my e-mail address unobfuscated in message bodies.
--
When in doubt, give it a good swift kick.