Vida Marcell Posted November 2, 2022 Share Posted November 2, 2022 I'm currently working with dlls in c++, and the first thing i noticed is this function __declspec(dllexport/import). There isn't too much explanations for it, but i think, the export if for making a function usable by other software that can acess the dll file, and the import is for the software to call a function from the dll? Am i correct? Quote Link to comment Share on other sites More sharing options...
reepblue Posted November 4, 2022 Share Posted November 4, 2022 Correct, It's also best to have one Macro for both import and export and define a lib preprocessor define for the library's project like so. #if defined (INPUTSYSTEM_LIB) #define INPUTSYTEM_API DLL_EXPORT #define INPUTSYTEM_API_GLOBAL DLL_EXPORT_GLOBAL #else #define INPUTSYTEM_API DLL_IMPORT #define INPUTSYTEM_API_GLOBAL DLL_IMPORT_GLOBAL #endif Then you make write your headers as so. class INPUTSYTEM_API IInputDriver { public: IInputDriver() {}; virtual ~IInputDriver() {}; }; INPUTSYTEM_API_GLOBAL void Init(); Working with DLLs can be a frustrating experience if your source tree isn't set up properly. You might want to consider public and private headers and expose the minimum to the other projects. Quote Cyclone - Ultra Game System - Component Preprocessor - Tex2TGA - Darkness Awaits Template (Leadwerks) If you like my work, consider supporting me on Patreon! Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.