none
_M_IX86 & _M_AMD64

    Question

  • I noticed that Visual Studio asserts _M_IX86 but when I am building for x64 the _M_AMD64 is not asserted. Do I need to manually #define this to activate the machine architecture? I would have thought the x64 build settings would have automatically set these switches.

    I have #defines for several candidate processors. I simply was wondering what is wrong with VS 2008 now.

    #if (defined (_M_ALPHA) && !defined(NT_INTEREX))


    #elif (defined (_M_IX86) && !defined(NT_INTEREX))


    #elif ((defined (_M_IA64) || defined(_M_AMD64)) && !defined(NT_INTEREX))

    ...


    I am a professional developer and I am registered with Microsoft Connect. I am also a vegan. Economics and chess are two of my many interests.
    Sunday, March 15, 2009 3:58 PM

Answers

  • Hi Vegan,

    I have tried to use Build->Configuration Manager->Active solution platform->new a platform:x64 as the document I have given you in last thread say. And add the following sinppet in my test application:

    #ifdef _M_AMD64  
         printf("AMD64");

    // My x64 code here  

    #elif defined (_M_IX86)  
         printf("IX86");

    // My x86 code here  

    #else

    #error !!! Need to write code for this architecture  

    #endif 


    It will output "AMD64" when running on real x64 platform but it will output the "IX86" on x86 platform even you set the x64 using configuation manager. I think it might be the reason. I'd like to suggest you to test your application on x64 platform.

    If you still have any problem, please feel free to tell me.

    Hope this helps,
    Nancy


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    • Marked as answer by Nancy Shao Friday, March 20, 2009 9:04 AM
    Wednesday, March 18, 2009 2:23 PM

All replies

  • Hi Vegan,

    Based on my understanding, this issue is to do with debugging property. Make the x64 Debug configuration the default, and then build the project.

    There is a good article Everything You Need To Know To Start Programming 64-Bit Windows Systems, which includes Developing for x64 with Visual C++ 2005 and Debugging techniques for your x64 builds, you could get detailed information there.

    If I misunderstand you, or you have any problem, please feel free to tell me.

    Hope this helps,
    Nancy 
    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    Wednesday, March 18, 2009 3:13 AM
  • Thanks Nancy Shao for your assistance.

     I am using x64 release settings, rather than debug. I have the compiler set for the most aggressive compler optimizations available as this program is an extreme performance project. The run time is measured in months and years so speed rather than code size is important, so everthing is inlined aggressively.

    I am using Visual Studio 2008 so I eas disappointed to see it still mired in the 32-bit world more than I like. Everthing I develop is now 64-bit as the world+dog are all going that way. I still think 64-bit is a short word, but that is another issue.

    I will look over that document, but the papers I have seen do not seem to go as deep as I need. Such as it is for me.

    The problem I see is that _WIN64 seems to be asserted fine, but not _M_AMD64 which I am trapping for SPU specific segments. My code has to run a a rage of processors besides the AMD64 CPU that desktop uses.

    When the code is open, the _M_IX86 block is shown as active and not the _M_AMD_64 that target. Of course I could hard code the thing, but that defeats the macro idea.

    I have to trap for the NT_INTEREX as the code base for that is a bit further down, I only showed 3 layers to make clear the issue I am investigating.


    IT/Developer, Windows/Linux/Whatever I need a new web server, the antique IBM 300GL has a 137GB disk limit, for my chess site. I wanted to post many more downloadable files, the existing 30GB disk is insufficient.
    Wednesday, March 18, 2009 3:18 AM
  • Hi Vegan,

    I have tried to use Build->Configuration Manager->Active solution platform->new a platform:x64 as the document I have given you in last thread say. And add the following sinppet in my test application:

    #ifdef _M_AMD64  
         printf("AMD64");

    // My x64 code here  

    #elif defined (_M_IX86)  
         printf("IX86");

    // My x86 code here  

    #else

    #error !!! Need to write code for this architecture  

    #endif 


    It will output "AMD64" when running on real x64 platform but it will output the "IX86" on x86 platform even you set the x64 using configuation manager. I think it might be the reason. I'd like to suggest you to test your application on x64 platform.

    If you still have any problem, please feel free to tell me.

    Hope this helps,
    Nancy


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
    • Marked as answer by Nancy Shao Friday, March 20, 2009 9:04 AM
    Wednesday, March 18, 2009 2:23 PM