Sign in to follow this  
Dark Star

Exporting object in DLLs

Recommended Posts

hi Forum, I know how to create DLLs but I was wondering how I would go about exporting objects and variables in a dll to the main applications. I know that when u have a function in a dll to be used in the main app, you write something like this before the function signature: __declspec(dllexport) void DoSomething() { //do something... } is this the same with the objects and variables u wanna export? If so, would I write this in the header file or cpp file or both? Thanks in advance DarkStar UK

Share this post


Link to post
Share on other sites
class __declspec(dllexport\import) TypeName
{
...
};

All static members should be declared export in the cpp files used to compile the DLL.

That is microsoft specific. I don't know about other windows compilers.

Share this post


Link to post
Share on other sites

Also make sure you put the __declaspec(dllexport) on the inner classes/structs. And the variables need a "extern __declaspec(dllexport)" in their declaration ... usually.

Quote:
Original post by Clash
All static members should be declared export in the cpp files used to compile the DLL.


I've never had to do declare static members with export...

Share this post


Link to post
Share on other sites
If you want the values of the static members available to the debugger, I've found that exporting them makes that happen. Not to mention, the Microsoft C++ compilers gives warnings when they are not exported.

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