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 has a blog entry What AnyCPU Really Means As Of .NET 4.5 and Visual Studio 11:
The reason is: in case you don't want to use more memory with 64 bit applicatios. Which means, if your application is AnyCPU, you want to run as 32 bit.
To add more, the setting in Visual Studio targets the particular CLR:
Please refer to the article 64-bit Applications (MSDN).