How to: Detect /clr Compilation
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer

How to: Detect /clr Compilation

Use the _MANAGED or _M_CEE macro to see if a module is compiled with /clr. For more information, see /clr (Common Language Runtime Compilation).

For more information about macros, see Predefined Macros.

// detect_CLR_compilation.cpp
// compile with: /clr
#include <stdio.h>

int main() {
   #if (_MANAGED == 1) || (_M_CEE == 1)
      printf_s("compiling with /clr\n");
      printf_s("compiling without /clr\n");
© 2016 Microsoft