I am a total newbie in C++, so please forgive my very elementary questions. I did google but could not find a sensible answer.
I used DevC++ to build and test a very simple project I found. It is supposed to make a DLL. AT this function I get error:
function 'int GetPluginInfo ...' definition is marked dllimport
Here is the code (I am sure it does not help much):
PLUGINAPI int GetPluginInfo( struct PluginInfo *pInfo )
{
*pInfo = oPluginInfo;
return TRUE;
}
Could you tell me what I could look for, to fix this? Since this is code I found and I know it works (for VC++ 6 at least), then maybe it has to do with the settings of Dev C++.
I have set the compiler options to create code for ISO C++11.
After more research I found the solution:
I have to set the follwing compiler options (Tools -> Compiler Options -> General):
-D__GNUWIN32__ -W -DWIN32 -DNDEBUG -D_WINDOWS -D_MBCS -D_USRDLL -DSAMPLE_EXPORTS -D_WINDLL -D_AFXDLL
Notice the -D_USRDLL. In a header file (plugin.h) there is the code:
// all exportable functions must have undecorated names
#ifdef _USRDLL
#define PLUGINAPI extern "C" __declspec(dllexport)
#else
#define PLUGINAPI extern "C" __declspec(dllimport)
#endif
So I guess the compiler option USRDLL forces the
#define PLUGINAPI extern "C" __declspec(dllexport)