Differences between version 4 and previous revision of CastingPointerToFunction.
Other diffs: Previous Major Revision, Previous Author, or view the Annotated Edit History
Newer page: | version 4 | Last edited on Monday, November 11, 2002 12:14:09 am | by PerryLorier | Revert |
Older page: | version 3 | Last edited on Sunday, November 10, 2002 8:58:56 pm | by CraigBox | Revert |
@@ -22,4 +22,7 @@
-----
And you need to do this why?
+
+1. Jon was using it to "compile" something then jump to it in C, by casting an array as a function, then calling it.
+2. I use it frequently to do things like have a lookup table of name to function. For example in ircu, theres a functino called "parse" which takes a line from a user, splits it up into a function and it's arguments, then scans through a table of functions and their names, when it finds one that matches that command, it calls the function with the arguments it parsed earlier. Nice 'n zippy.