zoukankan      html  css  js  c++  java
  • managed unmanaged

    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.
    ");
    }
    
    // #pragma managed
    #pragma managed(pop)
    
    // main is managed
    int main() {
       func1();
       func2();
    }
    
     
     
    In managed function.
    In unmanaged function.
  • 相关阅读:
    node.js require() 源码解读
    Nodejs源码解析之module
    nodejs代码初探之nodejs启动
    数字证书原理
    wsdl实例
    SOAP 格式设置选项
    JAVA RMI分布式原理和应用
    PAT乙级1053-----住房空置率 (20分)
    PAT乙级1071-----小赌怡情 (15分)
    PAT乙级1050-----螺旋矩阵 (25分)
  • 原文地址:https://www.cnblogs.com/ouyangping/p/7975570.html
Copyright © 2011-2022 走看看