如何:检测 /clr 编译

更新:2007 年 11 月

使用 _MANAGED_M_CEE 宏查看模块是否是使用 /clr 进行编译的。有关更多信息,请参见 /clr(公共语言运行库编译)

有关宏的更多信息,请参见 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");
   #else
      printf_s("compiling without /clr\n");
   #endif
}

请参见

参考

使用 C++ Interop(隐式 PInvoke)