Hi.
I have a dll I've written in visual studio 2005 standard.
It has a bunch of functions that are defined similarily to this
in a header:


__declspec(dllexport) int LoadStuff(int & parm1, char * parm2);
__declspec(dllexport) int UnLoadStuff(void);

Now, I load this library dynamically from another app developed in
another vendors older compiler.


There I have code like this in a header:

typedef int (* cdecl functionPointerLoadStuff)(int & parm1, char *parm2);
typedef int (* cdecl functionPointerUnLoadStuff)(void);

and in the same file I have this:
class myClass
{
public:
functionPointerLoadStuff functionLoadStuff;
functionPointerUnLoadStuff functionUnLoadStuff;
};

Finally in my class implementation I have code like this:

functionLoadStuff = (functionPointerLoadStuff )
GetProcAddress(hLibrary,"LoadStuff");

functionUnLoadStuff = (functionPointerUnLoadStuff)
GetProcAddress(hLibrary,"UnLoadStuff");



I'm wondering if there is some way to not have to maintain the header files
separately since in a sense they both code for the same interface. I'd rather
not have to separately update each one if at all reasonably possible.

I'm not so sure that the other vendors old compiler will recognize everything,
but I'm perusing the possibilities now.

Thanks





Jeff Kish

Re: dll interface specification and includes by Mark

Mark
Wed Jul 25 17:43:52 CDT 2007

I'm not sure if I'm following your question...

You show prototypes for exported functions and typefeds defining types for
function pointers.
There's nothing stopping you from keeping those in the same header file if
you want to (I personally would).

Mark
--
Mark Salsbery
Microsoft MVP - Visual C++

"Jeff Kish" <jeff.kish@mro.com> wrote in message
news:sjiea3p9s7o39busd5spf34hvmjhf1nh5h@4ax.com...
> Hi.
> I have a dll I've written in visual studio 2005 standard.
> It has a bunch of functions that are defined similarily to this
> in a header:
>
>
> __declspec(dllexport) int LoadStuff(int & parm1, char * parm2);
> __declspec(dllexport) int UnLoadStuff(void);
>
> Now, I load this library dynamically from another app developed in
> another vendors older compiler.
>
>
> There I have code like this in a header:
>
> typedef int (* cdecl functionPointerLoadStuff)(int & parm1, char *parm2);
> typedef int (* cdecl functionPointerUnLoadStuff)(void);
>
> and in the same file I have this:
> class myClass
> {
> public:
> functionPointerLoadStuff functionLoadStuff;
> functionPointerUnLoadStuff functionUnLoadStuff;
> };
>
> Finally in my class implementation I have code like this:
>
> functionLoadStuff = (functionPointerLoadStuff )
> GetProcAddress(hLibrary,"LoadStuff");
>
> functionUnLoadStuff = (functionPointerUnLoadStuff)
> GetProcAddress(hLibrary,"UnLoadStuff");
>
>
>
> I'm wondering if there is some way to not have to maintain the header
> files
> separately since in a sense they both code for the same interface. I'd
> rather
> not have to separately update each one if at all reasonably possible.
>
> I'm not so sure that the other vendors old compiler will recognize
> everything,
> but I'm perusing the possibilities now.
>
> Thanks
>
>
>
>
>
> Jeff Kish



Re: dll interface specification and includes by Jeff

Jeff
Thu Jul 26 12:34:56 CDT 2007

On Wed, 25 Jul 2007 15:43:52 -0700, "Mark Salsbery [MVP]"
<MarkSalsbery[MVP]@newsgroup.nospam> wrote:

>I'm not sure if I'm following your question...
>
>You show prototypes for exported functions and typefeds defining types for
>function pointers.
>There's nothing stopping you from keeping those in the same header file if
>you want to (I personally would).
>
>Mark
thanks Mark.

well, I'm wondering if there is some way of putting the most complex portion
of the declaration in a single typedef so that if a parameter changes or
something similar, I just need to change it in one place.

If not fine, I'll put both in the same file any ol' way.

regards
Jeff Kish