Skip to main content

Posts

Showing posts from December, 2012

Callback and Function pointer in C++ for interoping with .dll

We use many dynamic library and static library in a project for development purpose .The most way we use is call the various function from the .dll or .lib or any library.But sometimes it is needed to call the application function from .dll or .lib (application: who use the .dll / .lib). In programming literature it is called as callback .Now I will demonstrate how to call a function of an application to execute from library . For this purpose we will use function pointer.The way is like.... 1. app says     : "dll/lib keep my function address, which you will execute ". 2. dll/lib says : "Ok, I got it and stored it for future use". . . . 3. dll/lib says : "It is time I call you for work my application function". Step 0 : Declare the function pointer. i) typedef  void(*function)(void)   function : function address   void       : parameter(No) ii) typedef int(*function)(void) int   ...