This is a very important tip copied from MSDN about DLL class exporting. Although this can be found in MSDN, not too many novice programmers would be aware of it. Hence, I am posting it as a tip.
The complete article can be found here.
Compiler Warning (level 1) C4251
Visual Studio 2010
'identifier' : class '
type' needs to have DLL-interface to be used by clients of class '
To minimize the possibility of data corruption when exporting a class with __declspec(dllexport), ensure that:
- All your
static data is accessed through functions that are exported from the DLL.
- No inlined methods of your class can modify
- No inlined methods of your class use CRT functions or other library functions use
static data (see Potential Errors Passing CRT Objects Across DLL Boundaries for more information).
- No methods of your class (regardless of inlining) can use types where the instantiation in the EXE and DLL have
static data differences.
- Tip uploaded: 11th March, 2012