Export Functions

Started by
3 comments, last by glPerfect 22 years, 4 months ago
How can i export a class function?
Advertisement
By exporting the class.
And how?
__declspec (dllexport) DWORD MyFunction (arg1, arg2)
{
// TODO
}
Regards,synthexp
Okay, since this probably handles with DLL exporting, here''s a sample:

We have a class CPlayer which has member function Spawn(). We can either export the whole class:

class __declspec(dllexport) CPlayer
{
// .. blah .. //
};

or then just export the function:

__declspec(dllexport) void Spawn(vector3_t dir, vector3_t pos);

Either way, you have to consider which way to use very carefully. I do alot of OOP and I usually export the whole damn class. Usually, not always.

It might also be easier if you use a macro like this:
#ifdef YOURDLL_EXPORTS
#define YOURDLL_API __declspec(dllexport)
#else
#define YOURDLL_API __declspec(dllimport)
#endif
dump that into a header file and vóila! Then you can use the *****_API macro instead of the bloody __declspec() crap. Make sure you define the ***DLL_EXPORTS in your DLL.

- A.J. -
"Where is the KABOOM?! There was supposed to be an earth-shattering KABOOM!"
- A.J. -"Where is the KABOOM!? There was supposed to be an earth-shattering KABOOM!"

This topic is closed to new replies.

Advertisement