Error 2Error C2491: “SDK_functions::pinstance_” : definition of dllimport static data member is not allowed
This error occurred because I changed the export macro vs automatically created for me:
// The following ifdef blocks are a great way to make exporting from a DLL easier.
// Standard method for macros. All files in this DLL are defined on the command line using CYAPI_2013_EXPORTS
// Symbolic compilation. When using this DLL's
// This symbol should not be defined on any other project. In this way, any other item in the source file that contains this file will be
// The CYAPI_2013_API function is treated as imported from a DLL, which will be defined with this macro.
// Symbols are considered to be exported.
#ifdef CYAPI_EXPORTS
#define CYAPI_API __declspec(dllexport)
#else
#define CYAPI_API __declspec(dllimport)
#endif
As you can see, I manually dropped the 2013 characters, leaving the macro undefined by CYAPI_EXPORTS, and using succspec (DLlimport). Per declspec(DLlexport) is to be exported, for the person I have to write the export library with this; Succinct/DECLspec (DLlimport) is the import to be used by the people using the library.
In MSDN it says: you can compile the code correctly without using succdeclspec (DLlimport), but using succdeclspec (DLlimport) allows the compiler to produce better code. The compiler generates better code because it can determine whether a function exists in a DLL, which allows the compiler to generate code that skips the indirection level, which would normally occur in function calls across DLL boundaries. However, you must use succspec (DLlimport) to import the variables used in the DLL.
If someone wants to use the static variables in my library, they have to use succdeclspec (DLlimport) to import the variables in the DLL, so they have to export the variable using succdeclspec (DLlexport). For general variables, you don’t have to.