October 23, 2014
Hot Topics:
RSS RSS feed Download our iPhone app

C++ CLR Compilation

  • November 11, 2008
  • By Nick Wienholt
  • Send Email »
  • More Articles »



Click here for a larger image.

Figure 2: CLR Linker Options

Determining whether a DLL or EXE binary contains native or unverifiable managed code can be accomplished by using the PEVerify Tool that ships with the .NET Framework SDK. For native images and those compiled with the /clr compiler option, PEVerify will fail and report the existence of native code in the image. For /clr:pure images, PEVerify will report all the managed code that it detects that are not verifiably type-safe, and for /clr:safe images, PEVerify will report that all methods and types within the image are verifiably type-safe.

Conclusion

Choosing the correct CLR compilation mode depends on a number of factors, including the deployment and hosting strategies that the executable image will use in a production environment, and the extent to which native functionality like MFC, ATL, the CRT, and custom libraries will be used. Although any C++ project can have the /clr switch turned on, resulting in a managed executable being produced, there are progressively stricter requirements for achieving /clr:pure and /clr:safe compilation. Visual C++ is the only compiler that gives the developer the option of how the .NET Framework will be utilised by their code, and C++/CLI gives C++ developers that ability to produce managed types that are fully interoperable with other managed languages.

About the Author

Nick Wienholt is an independent Windows and .NET consultant based in Sydney. He is the author of Maximizing .NET Performance and co-author of A Programmer's Introduction to C# 2.0 from Apress, and specialises in system-level software architecture and development, with a particular focus of performance, security, interoperability, and debugging.

Nick is a keen and active participant in the .NET community. He is the co-founder of the Sydney Deep .NET User group and writes technical articles for Australian Developer Journal, ZDNet, Pinnacle Publishing, Developer.COM, MSDN Magazine (Australia and New Zealand Edition), and the Microsoft Developer Network. An archive of Nick's SDNUG presentations, articles, and .NET blog is available at www.dotnetperformance.com. In recognition of his work in the .NET area, he was awarded the Microsoft Most Valued Professional Award from 2002 through 2008.





Page 2 of 2



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Sitemap | Contact Us

Rocket Fuel