I am trying to write a dll, here is what my header file looks like:
#ifndef _DLL_H_
#define _DLL_H_
#if BUILDING_DLL
# define DLLIMPORT __declspec (dllexport)
#else
# define DLLIMPORT __declspec (dllimport)
#endif
DLLIMPORT void HelloWorld (void);
#endif
In the .cpp file, I include this header file, and I'm trying to declare a dll import procedure as follows:
DLLIMPORT void HelloWorld ()
{
MessageBox (0, "Hello World from DLL!n", "Hi", MB_ICONINFORMATION);
}
But the compiler (I have mingw32 on Windows 7 64 bit) continues to give me this error:
E:\Cpp\Sys64\main.cpp|7|error: function 'void HelloWorld()' definition is marked dllimport|
E:\Cpp\Sys64\main.cpp||In function 'void HelloWorld()':|
E:\Cpp\Sys64\main.cpp|7|warning: 'void HelloWorld()' redeclared without dllimport attribute: previous dllimport ignored|
||=== Build finished: 1 errors, 1 warnings ===|
And I donβt understand why.
source
share