任何CPU - 32不想位 [英] Any CPU - Prefer 32 bit

查看:124
本文介绍了任何CPU - 32不想位的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是任何CPU - 32不想位选择做什么?

What does the Any CPU - Prefer 32 bit option do?

虽然我知道的WinRT不能处理的exe,只能运行Windows Store应用程序,有几个问题的 中存在上的StackOverflow 是问同样的问题无一不参考这个的博客,上面写着:

While I am aware that WinRT can not handle exe and can only run Windows Store apps, there are several questions exist on StackOverflow that ask the same question and both reference this blog that says:

在.NET 4.5和Visual Studio 11奶酪已被移动。默认
表示最.NET项目再次值为anycpu,但有一个以上的
含义值为anycpu现在。还有一个额外的分型值为anycpu的,任何
CPU 32位的首选,这是新的默认(总体来说,有
现在为/平台的C#编译器开关五个选项:86,安腾,
64,值为anycpu和anycpu32bitpreferred)。当使用
值为anycpu那味道,语义如下:

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 that flavor of AnyCPU, the semantics are the following:


  • 如果这个过程在32位Windows系统上运行,它运行作为一个32位的
    的过程。 IL被编译为x86计算机代码。

  • 如果这个过程在64位Windows系统上运行时,它会作为一个32位的
    的过程。 IL被编译为x86计算机代码。

  • 如果进程中的一个ARM的Windows系统上运行,它会作为一个32位进程。 IL被编译为ARM机器代码。

  • If the process runs on a 32-bit Windows system, it runs as a 32-bit process. IL is compiled to x86 machine code.
  • If the process runs on a 64-bit Windows system, it runs as a 32-bit process. IL is compiled to x86 machine code.
  • If the process runs on an ARM Windows system, it runs as a 32-bit process. IL is compiled to ARM machine code.

不过,购买我的面放疗后,我创建了一个Hello World程序,将其设置为任何CPU,检查了32不想标志位,编译并将其复制到我的面。当我运行该程序的操作系统告诉我,它不能运行的程序,我应该放眼市场,因为它会为所有的x86 / x64的exe文件。显示的确切消息是:这个程序不能在您的PC上运行要找到这台PC的应用程序,打开Windows应用商店

However, after purchasing my Surface RT, I created a Hello World program, set it to Any CPU, checked the Prefer 32 Bit flag, compiled and copied it to my Surface. When I ran the program the OS told me that it could not run the program and that I should look to the marketplace as it would for any x86/x64 exe. The exact message displayed was: "This app can't run on your PC. To find apps for this PC, open the Windows Store."

那么,这实际上做,是有可能编译ARM的RT窗口任何CPU的应用程序?

So what does this actually do and is it possible to compile an Any CPU application for Window RT on ARM?

推荐答案

在您指定的报价仅仅根据,它表明,它意味着以下内容:

Based solely on the quote you specified, it suggests that it means the following:


  • 如果CPU支持32位处理,那么最终的机器代码将是32位(ARM或x86,无所谓)。

  • If the CPU supports 32-bit processing, then the final machine code will be 32-bit (ARM or x86, doesn't matter).

如果不是,那么本机代码将是64位。

If not, then the machine code will be 64-bit.

在古时,值为anycpu的意思是我是平台无关。这通常意味着你会得到在64位平台上的64位和32位的除外。

In the days of old, AnyCPU meant "I am platform agnostic." This typically meant that you would get 64-bit on 64-bit platforms, and 32-bit otherwise.

不过,也有原因,你可能需要32位甚至在64位CPU上:指针是一半大小,让你使用更少的内存;代码是更小,所以更适合高速缓存,等等。但是,有没有办法迫使CLR使用32位,并且仍保留在案件64位是必要的。

However, there are reasons why you may want 32-bit even on a 64-bit CPU: Pointers are half the size, so you use less memory; code is smaller, so more fits into the cache, etc. But, there was no way to force the CLR to use 32-bit, and still retain 64-bit in the cases it was necessary.

现在,随着值为anycpu - 32位的首选,你可以有你的蛋糕(64位支持在必要时)与(可能的时候支持32位),吃了太

Now, with AnyCPU - 32 bit preferred, you can have your cake (64-bit support when necessary) and eat it too (32-bit support when possible)

请注意:如果我没有弄错,安腾将只支持64位,而不是32位代码的平台。有可能会或可能不会被别人

Note: If I am not mistaken, Itanium would be a platform that only supports 64-bit, not 32-bit code. There may or may not be others.

免责声明:我不是专家,这只是从我读过过去6不同的博客文章个月左右

这篇关于任何CPU - 32不想位的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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