Richard said:
steve yee said:
#define M(i, j) ({ ++i; j; })
int main(int argc, _TCHAR* argv[])
{
int i = 0;
int j = M(i, 3);
return 0;
}
the above code can compile with gcc, but can't compile with most other
compilers. is it a gcc extension, or standerd feature?
It's an extension. The macro syntax is non-standard,
True, but there is a standard alternative...
#define M(i, j) (++(i), j)
Of course, I only _know_ this is a valid alternative because I know the
particular
gcc extension. [There are other forms on the extension which are not so
easy
to replicate in macro form.]
and the _TCHAR type is non-standard.
In the strictest sense, the identifier is standard in the sense that it
belongs
to a class of identifiers which are reserved for the implementation.
That said, it's use is obviously non-portable.
If most compilers can't compile it, that's a pretty reasonable clue that
it's non-standard!
More precisely, if most _conforming_ compilers (read... compilers
invoked in
conforming mode) can't compile it, it's a reasonable clue that it's
non-standard.
Many of the compilers I use will not compile trigraphs _unless_ they
are
invoked in conforming mode (or with trigraphs enabled.)