strings as functions

Henry Spencer henry at zoo.toronto.edu
Tue Jan 8 03:56:39 AEST 1991


In article <mpapp.663214690 at godzilla> mpapp@ (Mike Papper) writes:
>Is there a way to use a string value as the name of a function?
>In other words, can I use a string (possibly
>typed in by a programmer) as a function call to a function of
>the same name?

Not in standard C.  There has to be a table, somewhere, that maps names
into pointers to functions.  In a conventional implementation, that table
exists inside compiler and linker during compilation of the program, but
no longer exists at run time.  (It is sometimes present in the same file
that holds the executable program, but there is no fully portable way of
getting at that file or interpreting its contents.)  The only way to
implement such a feature portably is to decide in advance which functions
can be called this way, and provide your own table.
-- 
If the Space Shuttle was the answer,   | Henry Spencer at U of Toronto Zoology
what was the question?                 |  henry at zoo.toronto.edu   utzoo!henry



More information about the Comp.lang.c mailing list