473,396 Members | 1,775 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

What u mean by this statemnet ?.

what this statement &(*IR)->func means.

where IR is the pointer to structure & func is pointer to fuction.
func is the member of structure.

Jan 31 '06 #1
7 1381
Umesh said:
what this statement &(*IR)->func means.
This takes the address of the func object that is a member of a structure
that is pointed to by a pointer which is in turn pointed to by IR.

Let's start with IR.

IR is a pointer to a pointer to a struct.
*IR is a pointer to a struct.
(*IR)-> dereferences the struct.
(*IR)->func refers to the func member of the struct.
&(*IR)->func takes the address of the func member.
where IR is the pointer to structure


It isn't. At least, if it is, the compiler will emit a diagnostic for the
above code.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Jan 31 '06 #2
Umesh wrote:
what this statement &(*IR)->func means.

where IR is the pointer to structure & func is pointer to fuction.
func is the member of structure.


a->b is the same as (*a).b. Thus, IR cannot be a pointer
to struct but is a pointer to a pointer to struct, as
it is dereferenced twice:
(*IR)->func means (**IR).func
Now, you apply the address operator.
This gives you the address where the function pointer (**IR).func
is stored.

Observe:

#include <stdio.h>

int main (void)
{
struct test {
int filler;
void (*func)(void);
} instance, *pinst, **IR;
int offset = offsetof(struct test, func);

instance.filler = 0;
instance.func = NULL;
pinst = &instance;
IR = &pinst;

printf("inst: %p func: %p %p\n", (void *)(&instance),
(void *)(&instance.func), (void *)(&(*IR)->func));
printf("distance: %d %d\n", (int) offset,
(int) ((unsigned char*)(&(*IR)->func)-(unsigned char*)(*IR)));

return 0;
}
Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Jan 31 '06 #3
Thank you
Michael.

is it **IR.func & (*IR)->func is same.how ?

if yes how compiler interpret this statement.

Jan 31 '06 #4
Umesh said:

is it **IR.func & (*IR)->func is same.how ?


No.

(*IR)->func is equivalent to (**IR).func

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Jan 31 '06 #5
(*IR)->func is equivalent to (**IR).func

Then how compiler interpret this two statement.

Jan 31 '06 #6

Umesh wrote:
Richard Heathfield wrote:
(*IR)->func is equivalent to (**IR).func


Then how compiler interpret this two statement.


Please properly quote who said what. The first line above was by
Richard, and the second is your question, as far as I can see, so the
answer to your question is:

The compiler interprets these two in exactly the same way (i.e.
produces exactly the same code/behaviour). The two are obviously not
the /same/ (not spelled the same, if you want), but they mean /the same
thing/ to the compiler. Think of a->b as shorthand for (*a).b, and
things may be clearer. Thus:

(**IR).func <=> (*(*IR)).func <=> (*IR)->func

Cheers

Vladimir

Jan 31 '06 #7
Umesh wrote:
(*IR)->func is equivalent to (**IR).func

Then how compiler interpret this two statement.


Looks like you are trying to quote using the Google interface. The
information below may be of use.

Brian

--
Please quote enough of the previous message for context. To do so from
Google, click "show options" and use the Reply shown in the expanded
header.
Jan 31 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
by: Market Mutant | last post by:
www.51.ca is a nice site, and I want to build something similar and wonder if anyone knows if they are using PHPNuke or other nukes or they wrote everything themselves. What is the signature thing...
699
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
1
by: pxlpluker | last post by:
Not clear on what documentation means here. What exactly does the underlined text mean. w & a obviously mean you are going to update the file. So what does the + mean on w+ & a+ mean? Also please...
70
by: Roy Yao | last post by:
Does it mean "(sizeof(int))* (p)" or "sizeof( (int)(*p) )" ? According to my analysis, operator sizeof, (type) and * have the same precedence, and they combine from right to left. Then this...
125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
9
by: Marek Kurowski | last post by:
Yo! What mean when program is ALPHA or BETA version? I suppose it is not release version of program, but I don't know what it exactly mean. What it mean in your opinion? Marek Kurowski
8
by: Midnight Java Junkie | last post by:
Dear Colleagues: I feel that the dumbest questions are those that are never asked. I have been given the opportunity to get into .NET. Our organization has a subscription with Microsoft that...
12
by: Benjamin B. | last post by:
Hi everyone, in this thing I inherited there's a statement like this: a &= ~b; where a is an int and b has been declared this way: const b = 0x0002;
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.