Elegant and safe way to determine if architecture is 32bit or 64bit

后端 未结 7 1584
北恋
北恋 2021-01-19 01:47

As title says, is there any elegant and safe way to determine if architecture is 32bit or 64bit. By elegant, you can think of precise, correct, short, clean, and smart way.

7条回答
  •  無奈伤痛
    2021-01-19 02:31

    int iedx;
    
    __asm
    {
    
    mov eax, 0x80000001;
    cpuid;
    mov, iedx,edx;
    }
    
         if (iedx & (1 << 29))
           {
            return 1;
           }
         return 0;
    

提交回复
热议问题