Reputation: 701
Im getting several warnings saying I have inconsistent dll linkages despite me classifying the header of my dll like so:
#ifdef MY_ENGINE_EXPORTS
#define ENGINE __declspec(dllexport)
#else
#define ENGINE __declspec(dllimport)
#endif
It works fine to get rid of the errors when I add MY_ENGINE_EXPORTS to the preprocessor definitions but I was under the impression that this should be done automatically on build/export. Am I wording it wrong? I included an underscore because the project is 2 words e.g "my engine". I've tried it as both MY_ENGINE_EXPORTS and MYENGINE_EXPORTS but neither seems to work.
As I say I can just add it to preprocessor definitions but it's bugging me why it doesn't behave as it should.
Upvotes: 5
Views: 6512
Reputation: 942358
I figured it was a predefined macro that the environment created for dll projects
Yes, that does happen when you use the Win32 Project template to get the DLL project started. The wizard will automatically add the PROJECTNAME_EXPORTS preprocessor definition for you.
The wrinkle is that it cannot use a space in the symbol so it cannot use "MY PROJECT_EXPORTS". It will drop the space and make it MYPROJECT_EXPORTS. Which doesn't match with the one you used, MY_PROJECT_EXPORTS. Nothing a quick Edit + Replace can't fix of course.
Upvotes: 4