Inconsistent dll binding

I get some warnings that I have inconsistent DLL associations, even though I classify my dll header as follows:

#ifdef MY_ENGINE_EXPORTS #define ENGINE __declspec(dllexport) #else #define ENGINE __declspec(dllimport) #endif 

It works great to get rid of errors when I add MY_ENGINE_EXPORTS to the preprocessor definitions, but I got the impression that it needs to be done automatically during assembly / export. I'm not wrong? I included the underscore because the project consists of two words, for example, "my engine". I tried this as MY_ENGINE_EXPORTS and MYENGINE_EXPORTS, but none of them work.

As I said, I can simply add it to the preprocessor definitions, but it overhears me why it doesn't behave as it should.

+4
source share
1 answer

I realized that this is a predefined macro created by the environment for DLL projects

Yes, this happens when you use the Win32 project template to start a DLL project. The wizard will automatically add the PROJECTNAME_EXPORTS preprocessor definition for you.

The wrinkle is that it cannot use a space in the character, so it cannot use "MY PROJECT_EXPORTS". It will delete the space and make it MYPROJECT_EXPORTS. This does not match the one you used, MY_PROJECT_EXPORTS. Nothing quick editing + Replace can not fix, of course.

+3
source

Source: https://habr.com/ru/post/1468856/


All Articles