CONTENTS | INDEX | PREV | NEXT
INDIRECT FUNCTION POINTERS
DICE handles function pointers according to the -mr, -mR, -mRR
option specified:
-mr
function pointers are assigned the unregistered entry point
for procedures only, all calls through function pointers
use stack based arguments.
DICE generates both types of entry points for each procedure
definition.
-mR
function pointers are assigned the unregistered entry point
for procedures only, all calls through function pointers
use stack based arguments.
DICE generates only the registered (@) entry point for a
procedure definition.
-mRR
function pointers are assigned the unregistered entry point
if they are not prototyped (see below), the registered entry
point if they are. However, if the procedure was defined
with __stkargs, then the unregistered entry point will be
used.
calls through function pointers use stack args for unprototyped
function pointers, reg-args for prototyped function pointers.
WARNING: Any procedure assigned to a function pointer must
be declared in the same manner as the function pointer.
EXAMPLE, function table array:
struct entry {
char *funcName;
void (*funcPtr)(char *);
} *En;
extern void fubar(char *);
...
En->funcPtr = fubar;
En->funcPtr("this is a test");
Note how the function pointer in the entry structure is declared.
It is PROTOTYPED in of itself as taking a (char *). Any procedure,
such as fubar, that you might assign to this variable MUST BE
DECLARED IN THE SAME MANNER. In this case, it is:
extern void fubar(char *);
Which exactly matches the specification for the function pointer.
When you use the -mRR option matching the table with the functions
it is assigned with is IMPARATIVE. If you make a mistake, at
best DICE will warn you with a failed link (looking for an entry
point that does not exist). At worst, it will not warn you and
the program will operate improperly. It is suggested that you
use the -mr or -mR options until you get up to speed.