Bill Davidson wrote in
news:c1**************************@posting.google.c om in comp.lang.c++:
Hello there,
I need help on understanding part of the macro below:
#define MY_MACRO( OP, RESULT ) \
( (RESULT = (OP)) != 0 ? (errno = RESULT, -1) : 0 )
What I do not understand is how is the part (errno = RESULT, -1)
get evaluated.
The default behaviour of the , (comma) operator is to evaluate
the left expression and dicard the result and then to evaluate
the right expression:
value = ( evalute_and_dicard, result );
value = ( evalute_and_dicard, evalute_and_dicard_2, result );
Both of the above would assign result to value.
Assuming OP and RESULT in your example above are int's we could
rewrite it as:
inline int my_function( int op, int &result )
{
int return_value;
result = op;
if ( result != 0 )
{
errno = result;
return_value = -1;
}
else
{
return_value = 0;
}
return return_value;
}
HTH
Rob.
--
http://www.victim-prime.dsl.pipex.com/