Click here to Skip to main content
11,920,413 members (54,551 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


4 bookmarked

Minimize the Possibility of Data Corruption when Exporting a Class

, 10 Mar 2012 CPOL
Rate this:
Please Sign up or sign in to vote.
How to minimize the possibility of data corruption when exporting a class


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

Other Versions

'identifier' : class 'type' needs to have DLL-interface to be used by clients of class 'type2'.

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 static data.
  • 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


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Mukit, Ataul
Chief Technology Officer Rational Technologies
Bangladesh Bangladesh
Your Lord does not like people who waste by extravagance, and only the righteous C s, and does so in increments, and they are of those people who are mindful of what memory and time has in offer and they waste none of it.

You may also be interested in...

Comments and Discussions

-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.151120.1 | Last Updated 11 Mar 2012
Article Copyright 2012 by Mukit, Ataul
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid