Some Basic concepts

Published December 17, 2011
Advertisement
[subheading]DLL Basics[/subheading]
Since, we are going to be using dll's to have 1 single copy of our engine code, lets understand the basics of DLL's. For those of you, who are on the fence of whether to use a dll or not. Here are some of the advantages of using a dll as per MSDN

We will be using __declspec(dllexport) and__declspec(dllimport) to export and import functions, data and objects to and from a dll. We will mainly be using it to export/import functions or interface declarations and not member variables.

I prefer to have a header file which can encapsulate the above function calls. I will explain it with an example
#ifdef project_EXPORTS
#define project_API __declspec(dllexport)
#else
#define project_API __declspec(dllimport)
#endif

For the project from which we want to export functions, project_EXPORTS macro will be defined so that project_API automatically map to __declspec(dllexport). For all other projects project_API will map to __declspec(dllimport)

Now for whichever interface, we need to export all/the functions all we need to do is include the above header and add the following code
class project_API className
{
};

This takes care of exporting/importing all the functions, member variables in the class className.
Previous Entry Memory Leak Woes
Next Entry Free Stuff
1 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement