Any CPU - Prefer 32 bit

前端 未结 2 1710
陌清茗
陌清茗 2020-12-17 14:25

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

While I am aware that WinRT can not handle exe and can only run Windows Store apps, there are several questions exist

2条回答
  •  眼角桃花
    2020-12-17 15:10

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

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

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

    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.

    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.

    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)

    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.

    Disclaimer: I am not an expert, this is just from various blog posts that I've read over the last 6 months or so

提交回复
热议问题