xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

HB_FuncPtr()

Obtains the pointer to a function or procedure.

Syntax

HB_FuncPtr( <cFuncName> ) --> pFuncPointer

Arguments

<cFuncName>
This is a character string holding the symbolic name of an xHarbour function, or a declared user-defined FUNCTION or PROCEDURE.

Return

The return value is a pointer to <cFuncName> or NIL, when the symbolic name of the function or procedure does not exist at runtime.

Description

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.

Info

See also:@(), HB_Exec(), HB_ExecFromArray(), HB_ObjMsgPtr()
Category: Indirect execution , xHarbour extensions
Source:vm\hvm.c
LIB:xhb.lib
DLL:xhbdll.dll


Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe