Function Pointer Question

Nicholas Krause xerofoify at gmail.com
Thu Apr 2 06:54:42 EDT 2015



On April 2, 2015 6:15:19 AM EDT, Malte Vesper <malte.vesper at postgrad.manchester.ac.uk> wrote:
>Virtual functions are implemented on on the base of vtables, which in 
>turn are implemented using function pointers.
>So it would be good to get a grasp on functionpointers (they exist in 
>C++ as well), also I believe this is not a C mailing list, take a look 
>at stackoverflow or a c/c++ site or book of your choice.
>If you know how a pointer works, you will find it easy to understand
>how 
>a functionpointer works.
>
>On 02/04/15 05:16, Nicholas Krause wrote:
>> Greetings All,
>> I'm a little rough with how function pointers work in C. I assumed
>there similar to way C++ stores virtual functions internally in  the
>vtable for virtual functions  by the compiler and checks the table at
>runtime. Please let me know if I'm wrong in my understanding.
>> Thanks,
>> Nick
>>
I looked in to it and the kernel seems to be one of the few places where this is done along with in line functions.  Why do we need function pointers in the kernel, outside of device drivers is my real question and is there any way to do the code using them without function pointers at all, I am assuming no. 
Thanks, 
Nick 
-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.



More information about the Kernelnewbies mailing list