What does the “Prefer 32-bit” compiler flag mean f

2019-01-23 01:57发布

Just got the Visual Studio 11 developer preview installed. I see a new option in the project properties called "Prefer 32-bit" when compiling a managed (C#, VB) application with the AnyCPU target specified. This doesn't appear to be an option for class libraries, just top-level apps.

What does this flag indicate?

3条回答
虎瘦雄心在
2楼-- · 2019-01-23 02:27

It likely indicates the app is AnyCpu but when 32 bit is available it shouold run as such. This makes sense - 64 bit apps use more memory, and sometimes you just dont need the memory space ;)

查看更多
Fickle 薄情
3楼-- · 2019-01-23 02:32

There is an good article at What AnyCPU Really Means As Of .NET 4.5 and Visual Studio 11.

The short answer to your question is "When using that flavor of AnyCPU, the semantics are the following:

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. The difference, then, between “Any CPU 32-bit preferred” and “x86” is only this: a .NET application compiled to x86 will fail to run on an ARM Windows system, but an “Any CPU 32-bit preferred” application will run successfully."

查看更多
疯言疯语
4楼-- · 2019-01-23 02:53

EDIT: Application compiled with "Any CPU 32-bit preferred" is compatible with x86, x64 and ARM, while x86 is compatible only with x86, x64 and not ARM. For details see this.

查看更多
登录 后发表回答