On Aug 17, 2009, at 14:52, carlo.bramix wrote:
Hello,
if I understood the problem, I think it can be easily fixed without
using an inline function.
For example:
#ifdef __GNUC__
Relying on GCC-specific syntax is probably worse than an inline
function. Part of Ludovic's complaint was that we don't want to
depend on "inline" working in some random compiler; but then, we
certainly shouldn't depend on statement expressions working everywhere
either. And if you're going to conditionalize GCC and non-GCC
versions, you might as well use an inline function in the GCC case,
especially since other C99 compilers should support it as well. The
machinery in inline.h is set up to deal with that, though it chooses
between inline expansion and function calls, not between inline
function expansion and macro expansion. I think we can probably argue
that if inline function expansion is disabled for some reason in a
compiler that does support it, performance is not a key issue;
probably "-O" was omitted on the command line or something. So the
thought of falling back to a function call in that case really doesn't
bother me.
(I have written code to rely on GCC-specific extensions before, and
code that conditionalizes such things. I think there are cases where
you may want to do that. I just don't think this is one of them.)
The only benefits I see here to going with the macro are (1) minor
performance differences on non-C99, non-GCC compilers, (2) different
semantics if some odd type -- like a 64-bit value -- is provided, (3)
simpler code, if you just have one version of the macro.
Ken