rm****@yahoo.com wrote:
I have run across the following syntax in a C file -
if(funcAbc(paramXyz).mem2 == PASS)
{
...
}
I have never seen this syntax before, is it ANSI C or just something
the Greenhills toolset supports.
I think you'll find a clue to what's going on in funcAbc's return type.
(Do check that return type and try to figure it out for yourself.
Explicit explanation follows.)
This does not take a member of funcAbc _itself_, which would indeed be
incorrect; it takes a member of funcAbc()'s return value, which should
be a struct or union. Postfix operators, which include both () and .,
associate left-to-right; this expression is equivalent to
(funcAbc(paramXyz)).mem2. It first calls the function, and then applies
the member operator to the result. (It then compares this member's value
to PASS, but I presume that wasn't the part that confused you.)
Richard