Re: DLL export functions
From: Mike M (M_at_discussions.microsoft.com)
Date: 10/28/04
- Next message: BRG: "Re: NAN and +/- INF"
- Previous message: Victor Bazarov: "Re: NAN and +/- INF"
- In reply to: Murrgon: "Re: DLL export functions"
- Next in thread: Jochen Kalmbach: "Re: DLL export functions"
- Reply: Jochen Kalmbach: "Re: DLL export functions"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 28 Oct 2004 13:23:04 -0700
Instead of exporting a function from the dll that returns the set of
factories in a map maybe you can try the following bit of indirection...
void createFactory(IFactory **f);
void destroyFactory(IFactory ** f);
where IFactory is an abstract class that defines a method that will allow
you to retrieve your objects
class IFactory
{
virtual std::map<string, void *> get() = 0;
};
class SomeObjectFactory : public IFactory
{
std::map<string, void *> get()
{
//do what ever you need to do...
}
};
Note, the create/destroy functions exported from the DLL must be responsible
for allocating/deallocating the resources (i.e. memory) to avoid problems if
you mix-&-match each CRT differences per module.
Good luck
"Murrgon" wrote:
> Okay I have reached the stage where I am using very loud four
> letter words in my attempt to cross this DLL boundary. I have
> basically reached the conclusion that STL is a big POS and is
> the most unfriendly library I have ever had the misfortune to
> have to use.
>
> Given that, can someone suggest how I might be able to obtain
> the contents of a map that contains std:strings and pointers
> back from a DLL. The dll *must* be loaded dynamically (i.e.
> using LoadLibrary).
>
> Just as a note, I did try using a GetProcAddress on a full
> C++ mangled function name. I did get the function, but the
> result of passing back the map was the same: just garbage.
>
> Murrgon
>
> Jochen Kalmbach wrote:
> >>How are you supposed to get access to STL collections from within
> >>a DLL?
> >
> > Maybe I was not clear:
> > *You can“t return std::map in a simple extern "C" function*
> >
> > Either use C++ (std::map) and then you *must* use the lib to link with (and
> > therfor LoadLibrary/GetProcAddress will not work), or you specify an
> > *really* C function!
> >
> > (ok, for thoese how know that you also can LoadLibrary/GetProcAddress of
> > C++ => it is not supported and is a very bad hack!)
>
- Next message: BRG: "Re: NAN and +/- INF"
- Previous message: Victor Bazarov: "Re: NAN and +/- INF"
- In reply to: Murrgon: "Re: DLL export functions"
- Next in thread: Jochen Kalmbach: "Re: DLL export functions"
- Reply: Jochen Kalmbach: "Re: DLL export functions"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|