managed, unmanaged
来源:互联网 发布:窦靖童怎么变瘦的 知乎 编辑:程序博客网 时间:2024/05/18 01:39
摘自MSDNhttp://msdn.microsoft.com/en-us/library/0adb9zxe%28VS.80%29.aspx
托管以及不托管MSDN说明
Enable function-level control for compiling functions as managed or unmanaged.
#pragma managed
#pragma unmanaged
#pragma managed([push,] on | off)
#pragma managed(pop)
The /clr compiler option provides module-level control for compiling functions either as managed or unmanaged. An unmanaged function will be compiled for the native platform, and execution of that portion of the program will be passed to the native platform by the common language runtime. Functions are compiled as managed by default when /clr is used. Use the following guidelines when applying these pragmas: Add the pragma preceding a function but not within a function body. Add the pragma after #include statements (do not use these pragmas before #include statements). The compiler ignores the managed and unmanaged pragmas if /clr is not used in the compilation. When a template function is instantiated, the pragma state at the time of definition for the template determines if it is managed or unmanaged. For more information, see Initialization of Mixed Assemblies.// pragma_directives_managed_unmanaged.cpp
// compile with: /clr
#include <stdio.h>
// func1 is managed
void func1() {
System::Console::WriteLine("In managed function.");
}
// #pragma unmanaged
// push managed state on to stack and set unmanaged state
#pragma managed(push, off)
// func2 is unmanaged
void func2() {
printf("In unmanaged function./n");
}
// #pragma managed
#pragma managed(pop)
// main is managed
int main() {
func1();
func2();
}Output
In managed function.
In unmanaged function.
- managed, unmanaged
- Managed and Unmanaged code
- Managed/Unmanaged Code Interoperability
- Managed, Unmanaged,Native
- Managed code and Unmanaged code
- Managed Code and unmanaged Code
- managed domain与unmanaged domain
- managed, unmanaged (托管,非托管)
- vc ++.net2005 managed unmanaged mixing code
- An Overview of Managed/Unmanaged Code Interoperability
- Handling unmanaged memory pointers in managed memory
- Marshaling between Managed and Unmanaged Code
- Managed and Unmanaged Threading in Microsoft Windows
- managed and unmanaged code in c#
- managed code和unmanaged code混合debug
- managed code&unmanaged code&native code
- Managed, Unmanaged, Native: What Kind of Code Is This?
- CLR Inside Out: Marshaling between Managed and Unmanaged Code
- 关于Collections.sort
- Windows Phone 7 SDK 发布
- 几种值得用心体会的经典人生观
- 什么是委托
- 无法链接lex库
- managed, unmanaged
- erp系统介绍
- 一 道C语言试题的探讨
- .net中XML文件作为数据源的操作类
- 0314
- Linux 初始 RAM 磁盘(initrd)概述
- MySQL(root用户)密码忘记重置(Windows/Linux)
- nls_sort和nlssort 排序功能介绍
- php实现多线程