VS2013下的64位與32位程序配置
在Windows 7 64bit和Visual Studio 2013下生成64位程序。
- 新建一個Visual Studio Win32 Console項目,命名為WinTestX64.
代碼如下
#include "stdafx.h" #include <iostream> using namespace std; #define PRINT(a) cout << #a << ":" << a << endl void printSize(char aInFunc[]){ PRINT(sizeof(aInFunc)); } int _tmain(int argc, _TCHAR* argv[]) { char a[] = "abc"; char *b = "abc"; PRINT(sizeof(a)); PRINT(sizeof(b)); printSize(a); getchar(); return 0; }
- 在工具欄上單擊"Solution Platforms",選擇"Configuration Manager...",然后在"Active solution platform"中選擇"<New...>"
- 在"New Solution Platform"對話框中選擇"x64"平台。單擊確定。
- 回到IDE界面上了,注意到現在的平台已經是x64了。
- 編譯,鏈接,分別生成32位與64位程序。
- 按F5,開始調試,在output對話框中,我們可以看到32位和64位程序加載的dll不同。
32位程序從SysWOW64中加載dll。
而64位程序從System32中加載dll。
分別用32bit和64bit的配置編譯, 看看結果有何區別.