CPP/CLI 中的本机和托管之间是否令人困惑?
如果我使用 /clr 模式编译具有如下内容的代码:
int x = 3;
char ch='A';
int arr[]="Hi";
array<int>^ ManArr1={44};
array<int>^ ManArr2= gcnew array<int> {44};
我现在的问题: int
类型会映射到 System::Int32
吗?那么 char ch
呢?它们被视为本机类型还是托管类型?哪里会被处决!是否通过 MSIL!
我们看到 int arr[]
是一个原生数组,这是否意味着它将在 MSIL 之外执行?
最后一个问题,,对于托管数组 ManArr1
& ManArr2
两个初始化有什么区别?
If i use /clr mode to compile a code that has somthing like the following:
int x = 3;
char ch='A';
int arr[]="Hi";
array<int>^ ManArr1={44};
array<int>^ ManArr2= gcnew array<int> {44};
my questions now:
Would the type int
be mapped to System::Int32
?? and what about char ch
? Are they considerd as native or managed type? Where will be executed! through MSIL or not!!
We see that int arr[]
is a native array, does that mean it will be executed out of MSIL?
The last question ,, For both the managed array ManArr1
& ManArr2
what is the difference between the two initialization ??
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用
/clr
编译时,整个程序都会转换为 MSIL,除非您使用#pragma Managed(off)
或#pragma unmanaged
int
相当于System::Int32
char
相当于System::SByte
(不是System::Char
!)When compiling with
/clr
, your entire program is converted to MSIL unless you use#pragma managed(off)
or#pragma unmanaged
int
is equivalent toSystem::Int32
char
is equivalent toSystem::SByte
(notSystem::Char
!)关于
“对于托管数组ManArr1 & ManArr2这两个初始化有什么区别??”
没有功能上的区别,一个是另一个的简写。
Regarding
"For both the managed array ManArr1 & ManArr2 what is the difference between the two initialization ??"
There is no functional difference, one is a shorthand for the other.