xHarbour Reference Documentation > Function Reference |
Obtains the pointer to a function or procedure.
HB_FuncPtr( <cFuncName> ) --> pFuncPointer
The return value is a pointer to <cFuncName> or NIL, when the symbolic name of the function or procedure does not exist at runtime.
Function HB_FuncPtr() retrieves the pointer to an xHarbour function or a user-defined FUNCTION or PROCEDURE whose symbolic name must exist at runtime. Pointers to STATIC declared functions and procedures cannot be obtained at runtime.
A function pointer is the memory address of a function or procedure. It can be used with HB_Exec() or HB_ExecFromArray() to execute a function from its pointer. This is similar to embedding a function call within a code block and passing the block to the Eval() function. A code block can contain multiple function calls. If only one function is to be executed indirectly, a function pointer along with HB_Exec() or HB_ExecFromArray() is faster than code block execution.
The advantage of a function pointer is that the dynamic lookup of the symbolic function name can be avoided once the pointer is obtained. This can improve the performance of time critical functions considerably when they must be called very often.
See also: | @(), HB_Exec(), HB_ExecFromArray(), HB_ObjMsgPtr() |
Category: | Indirect execution , xHarbour extensions |
Source: | vm\hvm.c |
LIB: | xhb.lib |
DLL: | xhbdll.dll |
http://www.xHarbour.com