Path: utzoo!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!lll-winken!uunet!ingr!crossgl From: crossgl@ingr.com (Gordon Cross) Newsgroups: comp.lang.c Subject: Re: Functions pointers and stuff Keywords: Dynamic, pointers to functions Message-ID: <4693@ingr.com> Date: 29 Mar 89 14:56:47 GMT References: <1715@leah.Albany.Edu> Reply-To: crossgl@ingr.UUCP (Gordon Cross) Organization: Intergraph Corp. Huntsville, AL Lines: 25 In article <1715@leah.Albany.Edu> rds95@leah.Albany.Edu (Robert Seals) writes: }I got a question. Suppose I know the name of a function, like so: } } char *f = "A_Function"; } }and I got a function of the same name like so: } } void A_Function(void) { /* stuff */ } } }Is there some sneaky way to execute the function when all I know is }the name of it, i.e., a pointer to several letters which spell it's name. One way is to read the symbol table from the executable file. This requires that you can obtain the name of the file in all cases (someone could rename your program only to discover that doing so breaks it!!). The /proc file system (if you have one) provides an ioctl call to get an open file descriptor for the file. Even so, the "strip" command would then break your program... Simply put, there really is no better way (that I know of anyway) than the name/function-pointer table lookup you are doing now... -- Gordon Cross UUCP: uunet!ingr!crossgl "all opinions are 111 Westminister Way INTERNET: crossgl@ingr.com mine and not those Madison, AL 35758 MA BELL: (205) 772-7842 of my employer."