Login | Register  
Latest 20 PostsMinimize
09 Mar 2010 06:23 AM
09 Mar 2010 01:29 AM
08 Mar 2010 09:25 AM
08 Mar 2010 09:16 AM
08 Mar 2010 08:46 AM
08 Mar 2010 08:38 AM
07 Mar 2010 10:57 PM
07 Mar 2010 10:51 PM
07 Mar 2010 06:37 PM
07 Mar 2010 06:05 PM
07 Mar 2010 06:01 PM
07 Mar 2010 05:38 PM
07 Mar 2010 10:57 AM
07 Mar 2010 10:40 AM
07 Mar 2010 10:12 AM
07 Mar 2010 09:56 AM
07 Mar 2010 09:39 AM
07 Mar 2010 06:28 AM
07 Mar 2010 01:17 AM
06 Mar 2010 11:37 PM
ForumsMinimize
Difference between x86 and AnyCPU
Last Post 15 Sep 2009 05:12 AM byKarak. 1 Replies.
Printer Friendly
Sort:
NextNext
You are not authorized to post a reply.
AuthorMessages
FastalanasaUser is Offline
Grumpy Half-Elf
Advanced Member
Advanced Member
Send Private Message
Posts:555
Avatar

--
09 Sep 2009 08:13 AM  

I always have a hard time explaining why mixed OS in developer groups should use x86 instead of AnyCPU. I found an article that explains it in a real life context. The source for the article is here: http://laputa.sharpdevelop.net/SharpDevelopNowCreatesProjectsAs32bitByDefault.aspx

SharpDevelop now creates projects as 32-bit by default

Starting with SharpDevelop 3.1 RC2, new projects are created with a "Target CPU" setting of "x86". Previously, projects were created as "AnyCPU". This change affects only new projects; existing projects keep their old setting.

Now, what is the difference between these settings? On 32-bit Windows, there isn't any. But on 64-bit Windows, for programs, the "x86" setting means your program will run as a 32-bit process in the "Windows on Windows" emulation layer. AnyCPU programs would run as a native 64-bit process.
For libraries, the new setting will prevent them from being loaded into 64-bit processes.

Now, restricting stuff to 32-bit doesn't sound like it's the way forward. Why did we do this change?

   1. If you never test on 64-bit Windows, the new setting ensures your program will run in compatibility mode. This is better than breaking on your user's 64-bit machines because you unknowingly had 32-bit-only code in your program.
   2. The SharpDevelop debugger does not yet support 64-bit processes.
   3. Microsoft did the same change: Visual Studio 2010 also creates x86 projects by default.

The main problem with the target processor is that you cannot mix libraries with different processor types. If your program is running as 64-bit process, it cannot load 32-bit libraries. If your program is running as 32-bit process, it cannot load 64-bit libraries.
If you have an existing AnyCPU solution and add new projects to it using SharpDevelop 3.1, you should change the target CPU of all new projects back to AnyCPU.

As soon as your program depends on an unmanaged library, you will be forced to pick the corresponding processor type (e.g. SharpDevelop includes 32-bit SQLite and Subversion, so it must run as a 32-bit process). Unless your program is completely managed, AnyCPU is a bad idea because you would have to load a different unmanaged library depending on the process type your program got loaded into.

For purely managed libraries, the situation is different. Here I must recommend to use AnyCPU to allow your library to be loaded into any process type. In fact, in the case of SharpDevelop, only the executable (SharpDevelop.exe) is marked as 32-bit; all other libraries are AnyCPU.

KarakUser is Offline
Locutus of WheelMUD
Basic Member
Basic Member
Send Private Message
Posts:320
Avatar

--
15 Sep 2009 05:12 AM  
Nice. Maybe we should get rid of the 'any cpu' option until such time as we can effectively fix and test it on 64-bit machines and such? (I've found recently that adding x86 to a project that was missing it was easy, I imagine it would be the same for x64 or 'any cpu' options)
You are not authorized to post a reply.

Active Forums 4.1
Copyright 2007-2009 by WheelMUD  | Terms Of Use | Privacy Statement
Google Analytics Alternative