I saw this piece of code in an article I am reading.
class EXAMPLEUNMANAGEDDLL_API CUnmanagedTestClass
{
public:
CUnmanagedTestClass();
virtual ~CUn
This is for the purpose of exporting or importing the functions of a class into a DLL.
Read this article on MSDN for additional information: Using dllimport and dllexport in C++ Classes
The common practice is to use conditional compilation in the headers of the class, so that the same header can be used for producing the DLL or consuming the DLL:
#ifdef EXAMPLEUNMANAGEDDLL_EXPORTS
#define EXAMPLEUNMANAGEDDLL_API __declspec(dllexport)
#else
#define EXAMPLEUNMANAGEDDLL_API __declspec(dllimport)
#endif
In this example, the code or the buildscripts of your library would define symbol EXAMPLEUNMANAGEDDLL_EXPORTS
.
Such constructs are used in Windows to control whether the class is being used while building a DLL or it is being used to build a user of the DLL.
When building the DLL, EXAMPLEUNMANAGEDDLL_API
needs to expand to __declspec(dllexport)
.
When buidling users of the DLL, EXAMPLEUNMANAGEDDLL_API
needs to expand to __declspec(dllimport)
.
Further information can be found at: