C (37/274)

From:Jean-Bernard Delva
Date:04 Sep 2000 at 23:25:37
Subject:Re: calling lib functions from library

--- In amiga-c@egroups.com, "David McMinn" <dave@s...> wrote:
> Thanks for that, interesting to see that SAS/C has such neat features. However,
> I probably should have mentioned before that I'm using StormC v3, GCC and vbcc,
> so a solution for any of them would be OK. Sorry, my mistake.
>
> Hmm, I suppose it would be possible to do the same thing as SAS/C by hand,
> using some clever macros.

I don't know much about the compilers you are using in regards to shared
libraries. But if everything is done by hand, then all you have to do is follow
my method and use your prefixed functions in your function table.

SAS/C doesn't perform anything magical here. It simply associates the function
names found in the fd files with the ones found in your code that have the
specified prefix on them. It then builds the function table using these prefixed
functions.

As I said in my previous message, the caller will not see any of this as your
function interface still uses the unprefixed functions.

I hope you can use this method with your compiler as I think it is the cleanest
way to do it.

If you cannot, I know of another method but it is a little akward and requires
soem code. In short, you write stub functions that perform what #pragma libcall
would do. You write one function for each function in your interface and you
call these functions lets say Callxxx(). The implemenatation is simple. Have it
receive the library base as a parameter in a6 and simply jmp LVOOffset(a6).

As you can see its a riff on the initial method albeit more manual. And if
you happen to change your interface, you must remember to change the code in the
Callxxx() functions.

Anyway, I don't see why you cannot use my initial method with your compiler.

Keep me posted I'm interested to know if there are technical problems to it.

Jean-Bernard Delva