Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Note the following restrictions on the use of /clr:
- In a structured exception handler, there are restrictions on using - _allocawhen compiling with- /clr. For more information, see- _alloca.
- The use of run-time error checks isn't valid with - /clr. For more information, see How to: Use native run-time checks.
- When - /clris used to compile a program that only uses standard C++ syntax, the following guidelines apply to the use of inline assembly:- Inline assembly code that assumes knowledge of the native stack layout, calling conventions outside of the current function, or other low-level information about the computer may fail if that knowledge is applied to the stack frame for a managed function. Functions containing inline assembly code are generated as unmanaged functions, as if they were placed in a separate module that was compiled without - /clr.
- Inline assembly code in functions that pass copy-constructed function parameters isn't supported. 
 
- The - vprintfFunctions can't be called from a program compiled with- /clr.
- The - naked- __declspecmodifier is ignored under- /clr.
- The translator function set by - _set_se_translatorwill affect only catches in unmanaged code. For more information, see Exception handling.
- The comparison of function pointers isn't permitted under - /clr.
- The use of functions that aren't fully prototyped isn't permitted under - /clr.
- The following compiler options aren't supported with - /clr:- /EHscand- /EHs(- /clrimplies- /EHa(see- /EH(Exception Handling Model))
- /fp:strictand- /fp:except(see- /fp(Specify Floating-Point Behavior))
 
- The combination of the - _STATIC_CPPLIBpreprocessor definition (- /D_STATIC_CPPLIB) and the- /clrcompiler option isn't supported. It's because the definition would cause your application to link with the static, multithreaded C++ Standard Library, which isn't supported. For more information, see- /MD,- /MT,- /LD(Use Run-Time Library).
- When you use - /Ziwith- /clr, there are performance implications. For more information, see- /Zi.
- Passing a wide character to a .NET Framework output routine without also specifying - /Zc:wchar_tor without casting the character to- _wchar_twill cause the output to appear as an- unsigned short int. For example:- Console::WriteLine(L' ') // Will output 32. Console::WriteLine((__wchar_t)L' ') // Will output a space.
- /GSis ignored when compiling with- /clr, unless a function is under- #pragma unmanagedor if the function must be compiled as native code, in which case the compiler will generate warning C4793, which is off by default.
- See - /ENTRYfor function signature requirements of a managed application.
- Applications compiled with - /openmpand- /clrcan only be run in a single appdomain process. For more information, see- /openmp(Enable OpenMP 2.0 Support).
- Functions that take a variable number of arguments (varargs) will be generated as native functions. Any managed data types in the variable argument position will be marshaled to native types. Any System.String types are actually wide-character strings, but they're marshaled to single-byte character strings. So if a - printfspecifier is- %S(- wchar_t*), it will marshal to a- %sstring instead.
- When using the - va_argmacro, you may get unexpected results when compiling with- /clr:pure. For more information, see- va_arg,- va_copy,- va_end,- va_start. The- /clr:pureand- /clr:safecompiler options are deprecated in Visual Studio 2015 and unsupported in Visual Studio 2017 and later. Code that must be "pure" or "safe" should be ported to C#.
- You shouldn't call any functions that walk the stack to get parameter information (function arguments) from managed code. The P/Invoke layer causes that information to be further down the stack. For example, don't compile proxy/stub with - /clr.
- Functions will be compiled to managed code whenever possible, but not all C++ constructs can be translated to managed code. This determination is made on a function-by-function basis. If any part of a function can't be converted to managed code, the entire function will be converted to native code instead. The following cases prevent the compiler from generating managed code. - Compiler-generated thunks or helper functions. Native thunks are generated for any function call through a function pointer, including virtual function calls. 
- Functions that call - setjmpor- longjmp.
- Functions that use certain intrinsic routines to directly manipulate machine resources. For example, the use of - __enableand- __disable,- _ReturnAddressand- _AddressOfReturnAddress, or multimedia intrinsics will all result in native code.
- Functions that follow the - #pragma unmanageddirective. (The inverse,- #pragma managed, is also supported.)
- A function that contains references to aligned types, that is, types declared using - __declspec(align(...)).