VS2005调试C++

#include<iostream>
using namespace std;

void Func2(int *x)
{
    (*x)=(*x)+10;
}

int main(int argc,char*argv[])
{
    int n=0;
    Func2(&n);
    cout<<"n = "<<n<<endl;   
   
    return 0;
}

此时按f5启动调试,即会提示项目无法调试:无法找到“xxx.exe”的调试信息,或者调试信息不匹配。未使用调试信息生成二进制文件。 

1.先将项目degug模式改为release

问题在于,在空项目中不生成调试文件pdb,所以无法调试。

要让项目生成pdb文件,需要更改:

项目属性,configuration properties->linker->Generate Debug Info 从 no 改为 yes

项目属性,configuration properties->c/c++->debug information format为/ZI

项目属性,configuration properties->c/c++->optimization为Disabled

中文版:

项目属性->连接器->调试->生成调试信息->是(/DEBUG)

项目属性->C/C++->常规->调试信息格式->程序数据库(/Zi)

项目属性->C/C++->优化->优化->禁用(/Od)

原文地址:https://www.cnblogs.com/futao/p/1717839.html