Re: mixing calling conventions question
- From: "Avatar Zondertau" <avatarzt@xxxxxxxxx (please reply to newsgroup)>
- Date: 31 Oct 2005 04:30:10 -0700
> I have the following situation (simplified): a library (dll) I need
> (for data acquisition) comes in 2 versions. The main difference is
> the calling conventions: one is using stdcall and one is using cdecl.
> Now I have an import unit using dynamic loading, which is able to
> init the functions from either of the dlls. Of course I use some
> "ifdef" to mark the function variables with the proper calling
> convention. But this means I have to decide at compile time. I would
> like to be able to use a program with any of the dlls. Is there a way
> to do this? One solution is to duplicate the whole import unit for
> each situation and to make wrapper calls, but that's a lot new code.
> I was thinking of placing all functions in a table, redirect the
> calls to a small asm code that would unload the stack parameters in
> case of cdecl version. But how can I know the number of parameters??
>
> I am out of ideas, but I don't rush in implementing the wrapper calls
> yet. Maybe someone has a better idea.
I don't know exactly how much calls and how many different functions
we're talking about, but i would probably typecast the pointers to
function pointers at the last moment, using an if statement to
determine the type. This way you can decide at runtime.
This would mean declaring the function types twice:
TFooC = function (Bar: Integer): Integer; cdecl;
TFooS = function (Bar: Integer): Integer; stdcall;
and the calling lines themselves would be duplicated (for the if
statement). It would require no other changes.
--
The Fastcode Project: http://www.fastcodeproject.org/
.
- References:
- mixing calling conventions question
- From: Gabriel
- mixing calling conventions question
- Prev by Date: Re: FastObj update
- Next by Date: Re: Fastcode Move Library
- Previous by thread: Re: mixing calling conventions question
- Next by thread: REP RET
- Index(es):
Relevant Pages
|