Preprocessor Directive, Get target platform.

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Simple question really, I just need to know how I can determine if a Visual Studio 2005 project (c#) is set to target "Any Cpu", "x86", or "x64".  The program I am writing needs to be coded slightly differently depending on whether it is running on 32 bit windows, or 64 bit windows.  I want to use the #if preprocessor directive to determine if the platform target is x64 or not.  Basically I want to know if their is a #define variable based on the target platform, or will I have to create my own and change it every time I change target platforms.

I imagine myself having to do this,
<div style="text-align:left

<div style="text-align:left
<div class=codeseg>
<div class=codecontent>
<div class=codesniptitle><span style="width:100% Code Block
#define X_64

#if (X_64)
    //compile my X_64 specific code here
#else
   //compile my none x64 code here
#endif

I have looked all over the net to see if there is a #define symbol like that already set, but I cannot find anything.  Is there an easier way than the above, or is that the only way?

View the full article
 
Back
Top