home *** CD-ROM | disk | FTP | other *** search
- Submitted-by: barmar@think.com (Barry Margolin)
-
- In article <1992Feb22.073646.18830@uunet.uu.net> cmr@cvedc.prime.com (Chesley Reyburn) writes:
- >Thank you! I sent mail yesterday to Mr. Lewine stating the same
- >thing and proposing something like:
- >
- > void *(*local_func())(char *filename, char *entryname)
- ...
- >The only problem that I can see is that the above function
- >limits the new functions to always only returning a pointer
- >to void.
-
- I don't think that's a problem. The caller should be required to cast the
- returned pointer to the actual type of the function that is being linked
- in. So, if you're trying to dynamically load a function that returns an
- int, you would write:
-
- int (*foo_fun)();
- foo_fun = (int (*)()) local_func(filename, entryname);
-
- BTW, why did you specify void* in the first place? Since the default
- return type in C is int, it would probably be more intuitive for
- local_func() to return an int function rather than a void* function.
- Another reasonable default would be a void function. But either way, the
- caller will have to cast it if the default isn't appropriate for that
- function.
-
- --
- Barry Margolin
- System Manager, Thinking Machines Corp.
-
- barmar@think.com {uunet,harvard}!think!barmar
-
-
- Volume-Number: Volume 27, Number 4
-
-