Enable function-level control for compiling functions as managed or unmanaged.

 
 
#pragma managed
#pragma unmanaged
#pragma managed([push,] on | off)
#pragma managed(pop)
Remarks

 
 

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.

Example

 
 
 
 
// 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();
}
 
 
In managed function.
In unmanaged function.

managed unmanaged的更多相关文章

  1. Investigating issues with Unmanaged Memory. First steps. (转载)

    原文:http://kate-butenko.blogspot.tw/2012/07/investigating-issues-with-unmanaged.html I want to write ...

  2. 《Walking the callstack(转载)》

    本文转载自:https://www.codeproject.com/articles/11132/walking-the-callstack Download demo project with so ...

  3. Windbg使用简明指南

    第一章 准备 1.1.    环境配置 _NT_DEBUGGER_EXTENSION_PATH=C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727 _NT_SY ...

  4. Gumshoe - Microsoft Code Coverage Test Toolset

    Gumshoe - Microsoft Code Coverage Test Toolset 2014-07-17 What is Gumshoe? How to instrument a binar ...

  5. Chapter 6 — Improving ASP.NET Performance

    https://msdn.microsoft.com/en-us/library/ff647787.aspx Retired Content This content is outdated and ...

  6. C#使用MiniDump捕获异常

    c/c++语言里MiniDump是一个重要的调试手段,他们没有C#/java这样语言有很多异常输出信息( JVM异常导出bug日志功能,通常在jdk目录,文件格式hs_err_%pid%.log,pi ...

  7. Rewrite MSIL Code on the Fly with the .NET Framework Profiling API

    http://clrprofiler.codeplex.com/ http://blogs.msdn.com/b/davbr/archive/2012/11/19/clrprofiler-4-5-re ...

  8. Jetty - Container源码分析

    1. 描述 Container提供管理bean的能力. 基于Jetty-9.4.8.v20171121. 1.1 API public interface Container { // 增加一个bea ...

  9. C# .Net Framework4.5中配置和使用managedCUDA及常见问题解决办法

    主要参考英文帖子.我就不翻译了哈.很容易懂的. 先说明我的运行平台: 1.IDE:Visual Studio 2012 C# .Net Framework4.5,使用默认安装路径: 2.显卡类型:NV ...

随机推荐

  1. iOS - runtime 常用方法举例说明

    使用的自定义类,如下: #import <Foundation/Foundation.h> @interface Person : NSObject @property(nonatomic ...

  2. CSS 利用border三角形绘制方法

    CSS 三角形绘制方法,这里面的transparent比较重要,有和没有影响很大: 原理:这个div是由4个三角形组成,每个三角对应一个border,隐藏其它3个border,就可以得到一个三角形. ...

  3. 系统有问题基本出在数据库上,web层无状态

    系统有问题基本出在数据库上,web层无状态.

  4. 安装python3后,没有Scripts目录的解决办法

    设置好python环境变量后,执行命令即可:python -m ensurepip

  5. 卓越管理的实践技巧(1)如何进行有效的指导 Guidelines for Effective Coaching

    Guidelines for Effective Coaching 前文卓越管理的秘密(Behind Closed Doors)最后一部分提到了总结的13条卓越管理的实践技巧并列出了所有实践技巧名称的 ...

  6. UVA 12898 - And Or 与和或 (思路题)

    思路就是有零一变化的位Or以后一定是1,And以后一定是0:那么如果b的二进制更长那么就把包含a的部分全部置为1或0,如果一样长那么就把不同的部分置为1或0. 今天被这题坑的地方:1默认是int,如果 ...

  7. eclipse报错GC overhead limit exceed,卡顿

    在使用Eclipse的Build Project功能时,提示以下错误: An internal error occurred during: “Build Project”. GC overhead ...

  8. Linux连接外网

    1.给linux配置ip 进行远程管理 如果网络不同的话需要配置网卡,命令如下: vi /etc/sysconfig/network-scripts/ifcfg-enp0s3   回车 就出现网络的环 ...

  9. 03_4_this关键字

    03_4_this关键字 1. this关键字 在类的方法定义中使用的this关键字代表使用该方法的对象的引用. 当必须指出当前使用方法的对象是谁时要使用this. 有时使用this可以处理方法中成员 ...

  10. atomic nonatomic区别

    摘要 atomic和nonatomic区别用来决定编译器生成的getter和setter是否为原子操作.atomic提供多线程安全,是描述该变量是否支持多线程的同步访问,如果选择了atomic 那么就 ...