🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #51916

access to function by strings

#51916
From: jasnoch
Date: Tue, 09 Mar 1993 13:35
31 lines
1408 bytes
I have a problem by executing a function:

I want to execute a "unknown" function corresponding to an user input.
This function exist in the complete executabel program, but the main
part did not know about. So, it is impossible to do it this way:

struct init {
  char *fname;
 double (*fnctn)(...);
};
struct init arith_fncts[] = {
 "sin", sin
      :
};

Suppose that this "calculator" should be able to call any user-defined
function, which is linked to the main program, e.g. by a library.


So, doe's there exist the possibility to get the corresponding function pointer
by the name of the function, e.g.:

typedef double (*Fnctn)(...);
Fnctn fnctn;

fnctn = get_function_pointer (char*);

where (char*) is the name of a funtion.

Thanks in advance for your help,
  Uwe Jasnoch
Technical Details
Message-ID: <9303091329.AA09997@haegar.grz>
Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!agate!spool.mu.edu!uwm.edu!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!cis.ohio-state.edu!igd.fhg.DE!jasnoch

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,737fbb20ae1191c4,start
X-Google-Attributes: gid11318c,public
X-Google-ArrivalTime: 1993-03-09 06:21:32 PST
Path: arc1-ca.pugleaf.net!sparky!uunet!stanford.edu!agate!spool.mu.edu!uwm.edu!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!cis.ohio-state.edu!igd.fhg.DE!jasnoch
From: jasnoch@igd.fhg.DE
Newsgroups: gnu.gcc.help
Subject: access to function by strings
Date: 9 Mar 1993 08:35:12 -0500
Organization: GNUs Not Usenet
Lines: 31
Sender: daemon@cis.ohio-state.edu
Distribution: gnu
Message-ID: <9303091329.AA09997@haegar.grz>