“首选32位”功能的目的是什么?在Visual Studio中设置,它实际上如何工作? [英] What is the purpose of the "Prefer 32-bit" setting in Visual Studio and how does it actually work?

查看:307
本文介绍了“首选32位”功能的目的是什么?在Visual Studio中设置,它实际上如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

它是我不清楚编译器在需要时如何自动知道要针对64位进行编译。

It is unclear to me how the compiler will automatically know to compile for 64-bit when it needs to. How does it know when it can confidently target 32-bit?

我主要是想知道编译器在编译时如何知道要针对哪种体系结构。

I am mainly curious about how the compiler knows which architecture to target when compiling. Does it analyze the code and make a decision based on what it finds?

推荐答案

Microsoft是否有博客条目 AnyCPU在.NET 4.5和Visual Studio 11中的真正含义

Microsoft has a blog entry What AnyCPU Really Means As Of .NET 4.5 and Visual Studio 11:


在.NET 4.5和Visual Studio 11中,奶酪已被移动。大多数.NET项目的
默认值仍然是AnyCPU,但是AnyCPU现在有超过
的含义。还有一个AnyCPU子类型,
首选32位CPU,这是新的默认设置(总的来说,
现在是/ platform C#编译器开关的五个选项:x86,
首选Itanium,x64,anycpu和anycpu32bit)。当使用AnyCPU的首选32位
样式时,语义如下:

In .NET 4.5 and Visual Studio 11 the cheese has been moved. The default for most .NET projects is again AnyCPU, but there is more than one meaning to AnyCPU now. There is an additional sub-type of AnyCPU, "Any CPU 32-bit preferred", which is the new default (overall, there are now five options for the /platform C# compiler switch: x86, Itanium, x64, anycpu, and anycpu32bitpreferred). When using the "Prefer 32-Bit" flavor of AnyCPU, the semantics are as follows:


  • 如果进程运行在一个32位Windows系统,它作为32位进程运行。 IL被编译为x86机器代码。

  • 如果该进程在64位Windows系统上运行,则它将作为32位进程运行。 IL被编译为x86机器代码。

  • 如果该进程在ARM Windows系统上运行,则它将作为32位进程运行。 IL被编译为ARM机器代码。

然后,任何CPU 32位首选和 x86仅是
:编译为x86的.NET应用程序将无法在
ARM Windows系统上运行,但是任何CPU 32位首选应用程序将成功运行

这篇关于“首选32位”功能的目的是什么?在Visual Studio中设置,它实际上如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆