Sign in to follow this  
Uphoreum

Passing Structs to a Dynamically Loaded DLL

Recommended Posts

I've been looking into dynamically loading DLLs to create a modular plug-in architecture. All the examples I've seen only pass basic C types like int, char, and void* through the function pointers. Is it not possible/a bad idea to send custom struct instances to a dynamically loaded DLL? If so, do I just pass void pointers around? Thanks!

Share this post


Link to post
Share on other sites
Is the dll one you wrote? If so what's the problem? A dynamic dll is loaded into the same address space as a statically linked dll. The address space belongs to the process. That address space includes dynamically allocated structs from the heap just as it does statically allocated hard coded structs. Pass struct pointers if you like.

Share this post


Link to post
Share on other sites
You run into some issues passing any struct or class that is not POD between DLLs, but regular structs with nothing but data members are fine. Just use a pointer to the struct as the previous poster mentioned. If you need the structs to contain methods, then it becomes a little less desirable, although it's still certainly do-able by using dll exporting / importing.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this