DLL Function Pointer Call in Non-DLL Code

The C/C++ compiler supports the DLL function pointer call in non-DLL code. You can, therefore, create a DLL to support both DLL and non-DLL applications. To make those calls possible, glue code is included at the beginning of a function descriptor to allow branching to a function descriptor.

A function pointer in non-DLL code points to the function entry, and a function pointer call branches to the function address. However, when a DLL function pointer is passed from DLL code to non-DLL code, the pointer points to a function descriptor. A call made through this pointer in non-DLL code results in branching to the descriptor.

The C/C++ compiler executes a DLL function pointer call in non-DLL code by branching to the descriptor and executing the glue code that invokes the actual function.

The example below and in Figure 4 show a DLL function pointer call in non-DLL code, where a simplified qsort() routine is used as an example of non-DLL code. Note that the qsort() routine compiled as non-DLL code can be called from both a DLL application and a non-DLL application.