Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
The dllexport and dllimport extended storage-class modifiers are Microsoft-specific extensions to the C and C++ languages. They enable you to export and import functions, data, and objects to and from a DLL.
__declspec( dllimport )declarator__declspec( dllexport ) declarator
These attributes explicitly define the DLL interface to its client, which can be the executable file or another DLL.
Declaring functions as dllexport eliminates the need for a module-definition (.DEF) file, at least with respect to the specification of exported functions.
Note that dllexport replaces the __export keyword.
The declaration of dllexport and dllimport must use extended attribute syntax and the __declspec keyword.
Example
// Example of the dllimport and dllexport class attributes
__declspec( dllimport ) int i;
__declspec( dllexport ) void func();
Alternatively, to make your code more readable, you can use macro definitions:
#define DllImport __declspec( dllimport )
#define DllExport __declspec( dllexport )
DllExport void func();
DllExport int i = 10;
DllImport int j;
DllExport int n;
See Also
__declspec | DLL Interface Declarations
Send Feedback on this topic to the authors