accessing struct elements of a function return

R

rmsprm

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. Looks like reverse C++ but the
compilers takes it without warnings.
 
B

baumann@pan

why not?

if funcAbc return value of type struct which has member mem2, i think
it's ok
 
R

Richard Bos

baumann@pan said:

Why _what_ not? If you must use Google Broken Beta to read Usenet (but
do yourself a favour; get a newsreader), then please at least get it to
post as correctly as it is capable of - which includes, at the least,
proper quoting. I'm led to believe there is a button on the posting page
that lets you do so.

Richard
 
R

Richard Bos

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
 
D

Default User

Richard said:
Why _what_ not? If you must use Google Broken Beta to read Usenet (but
do yourself a favour; get a newsreader), then please at least get it to
post as correctly as it is capable of - which includes, at the least,
proper quoting. I'm led to believe there is a button on the posting page
that lets you do so.


The way to do it from Google is to click "show options", then use the
Reply shown in the expanded header.

Damn, I wish they would fix that. I am stuck posting through Google
(although able to read though my normal newsreader, thankfully).



Brian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,161
Messages
2,570,892
Members
47,428
Latest member
RosalieQui

Latest Threads

Top