Path: utzoo!attcan!uunet!sugar!peter From: peter@sugar.uu.net (Peter da Silva) Newsgroups: comp.sys.amiga Subject: Re: libraries & function-calling Message-ID: <2719@sugar.uu.net> Date: 1 Oct 88 12:46:43 GMT References: <209@tekn01.chalmers.se> Organization: Sugar Land Unix - Houston, TX Lines: 31 In article <209@tekn01.chalmers.se>, d85_kitte@tekn01.chalmers.se (Kristian Wedberg) writes: > I want the user to call a function foo() in my library. foo() is part > of the normal Amiga-functions, and in my library I want to call the > Amiga-version of foo(), not my own. Is this possible? I'm using > macros and a different name now, but that is not altogether satisfactory. Ah, this would be so easy in Forth: : foo ... foo ... ; /* Call old version of foo in foo */ : foo ... [ smudge ] foo [ smudge ] ... ; /* Recursive call */ In 'C'? Macros and a different name. You could also SetFunction it, but there isn't a safe way to do this in general without worrying about: proga setfunctions foo progb setfunctions foo proga restores foo & exits (prog b's setfunction now invalid) progb restores foo and exits (foo now pointing to proga's foo) anyone calls foo. guru. You can always check to see if foo has been changed behind your nack and not restore it, but that still leaves the possibiliy of someone invalidating your setfunction. If you know that Lattice always calls foo through a glue routine, you can always duplicate the glue routine with another name and override it with your code at link time. This won't help with, say, M2Amiga or with any future version of the 'C' compiler that does the libcall directly. -- Peter da Silva `-_-' peter@sugar.uu.net Have you hugged U your wolf today?