http://blog.csdn.net/infoworld/article/details/10958583
场景:
1.编译器没有显式的指定。
2.需要根据32,64做不同的处理.
方法1:
- #include "stdio.h"
- int main(int argc,char * argv[])
- {
- void* number = 0;
- printf("%d\n",sizeof(&number));
- }
输出8就是64位的,4就是32位的。根据逻辑地址判断。
方法2:
可以用file命令判断(如果安装了msys的话,linux下应该自带)
file msys-expat-1.dll
- msys-expat-1.dll: PE executable for MS Windows (DLL) (console) Intel 80386 32-bi
- t
方法3:
- If you have a hex editor program, just open your file with it and shortly after the standard header intro stuff (like
- "This program cannot be run in DOS mode...") you will see either
- "PE..L" (hex code: 504500004C) = 32 bit
- or
- "PE..d†" (hex code: 504500006486) = 64 bit
- 随手UE打开了两个exe,果然有效。但是这个50450000????的位置不确定,大致在00000100h附近。
- 另 exe 文件头的典型提示字串未必统一。如一个是This program cannot be run in DOS mode,另一个是
- This program must be run under Win32
方法4:
vs的工具dumpbin,参数/HEADERS
64 bit
- E:\software\TDM-GCC-64\bin>dumpbin /HEADERS libgcc_s_seh_64-1.dll
- Microsoft (R) COFF/PE Dumper Version 10.00.40219.01
- Copyright (C) Microsoft Corporation. All rights reserved.
- Dump of file libgcc_s_seh_64-1.dll
- PE signature found
- File Type: DLL
- FILE HEADER VALUES
- 8664 machine (x64)
32 bit
- E:\software\TDM-GCC-64\bin>dumpbin /HEADERS g++.exe
- Microsoft (R) COFF/PE Dumper Version 10.00.40219.01
- Copyright (C) Microsoft Corporation. All rights reserved.
- Dump of file g++.exe
- PE signature found
- File Type: EXECUTABLE IMAGE
- FILE HEADER VALUES
- 14C machine (x86)