Incorporating Users' Functions
Denis Dowling
dpd at mullian.ee.mu.oz.au
Tue Sep 18 13:51:03 AEST 1990
In article <11954 at crdgw1.crd.ge.com> larocque at jupiter.crd.ge.com (David M. LaRocque) writes:
>I'm looking for suggestions on the best technique to incorporate
>user-written functions into a software package I'm developing.
>could be dealt with with the varargs facility.
[Description Deleted]
>I suppose what might be ideal is to have the user create all his
>functions in a separate file that is compiled into the main
>program. Then I think the problem becomes finding out what a
>function's pointer is when one only knows the name of the function.
Have you had a look at the nlist(3) call? The synopsis is given below.
NAME
nlist - get entries from symbol table
SYNOPSIS
#include <nlist.h>
int nlist(filename, nl)
char *filename;
struct nlist *nl;
This will return the symbol table entry for the specified symbol.
The nlist structure has a value field that can be cast to a function pointer.
I have used this for a system similar to what you describe.
I do not know of any clean way to deal with function arguments though. What
is needed is a reverse form of varargs that allows the construction of an
argument list for passing to a function. Anyone have any ideas?
It might pay you to have a look at the recent postings in alt.sources on
dynamic loading of proceedures in unix. This can allow functions to be
loaded on the fly as needed and not have to be explicitly linked with the
executable program.
>
>Thanks, Dave
>
>/**************************************************
> * larocque at crd.ge.com (518) 387-5805
> * ...!crdgw1!cetus.crd.ge.com!larocque
> **************************************************/
______________________________________________________________________________
Denis Dowling ACSnet : dpd at mullian.mu.oz
SITEE - (Elec Eng) uunet : uunet!munnari!mullian!dpd
University of Melbourne internet : dpd at mullian.mu.oz.au
More information about the Comp.lang.c
mailing list