Home > Back-end >  How C language from the source function to obtain the address of a function pointer pointing to it
How C language from the source function to obtain the address of a function pointer pointing to it

Time:09-17

Assume that there are multiple function pointer, the function pointer is a member of the structure variable,
These function Pointers point to the same source function,
When the change from a function pointer call source function, how to obtain the function from the source function pointer address,
Description as shown in the appended drawings,
Please give complete ideas and code,

CodePudding user response:

As if in front of the ebp

CodePudding user response:

Seem to do less than, can be in fn_t, add a parameter test *, typedef int (* fn_t) test (*)
Or to define him as a member of the test function typedef int (test: : * fn_t) ()

CodePudding user response:

reference response: 1/f, qian dream life
as if in front of the ebp

No, not this,
Can't, don't know how to make,
Unless, that is, the source function belongs to the test, then can study using polymorphism, inheritance of what

Otherwise only passed directly or indirectly to the pointer

CodePudding user response:

Because of this common calls, which one do you want to return to the specific structure of the data, the different position, different structure
C language nor thiscal, help you tell the function is the underlying create into this pointer in which the structure of the data,
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Straight view is:
Your t1
Memory: 10001 ~ 10002
Your t2
Memory: 20001 ~ 20002

And function of the one and only one, want to pay
Want to return I value, the function also wondered: you is that I want 10000 that fudge, or 20000 on the rocks that I?

CodePudding user response:

reference response: 1/f, qian dream life
as if in front of the ebp

Today I thought for a moment, the idea is really a train of thought

CodePudding user response:

If say the iterator to implement in C language, now begin not preach, isn't it similar to the problem,

CodePudding user response:

Brother????????

CodePudding user response:

Iteration is used too little, is not very good,

Ebp is calling a function that line of code in front of the next line of code,
Then through the pointer to find a line up call XXXXXX, see [XXXXXXX] is what,

Pure C language unless pass, does not have any good idea

CodePudding user response:

refer to the eighth floor response: thousand dreams life
iteration is used to too little, is not very good,

Ebp is calling a function that line of code in front of the next line of code,
Then through the pointer to find a line up call XXXXXX, see [XXXXXXX] is what,

Pure C language unless pass, does not have any good ideas

Then through the pointer to find a line up the call (XXXXXX), take a look at XXXXXXX is what,
  • Related