Visual Studio 2017,C++,在单步执行代码时指向错误的行

Visual Studio 2017, C++, pointing a wrong line while stepping through the code

本文关键字:错误 代码 执行 2017 Studio C++ 单步 Visual      更新时间:2023-10-16

在某些文件中,调试器在单步执行代码时指向错误的行。准确地说,它完全偏离了一行(总是(

我已经尝试过:

1) normlized line-endings in all of the files
2) wiped out all of the PDB files
3) wiped out the entire debug folder
4) rebuilt the entire project
5)ensured that optimisation for the entire solution and projects within it it is turned-off (/Od switch enabled)
6)ensured that libraries (*.LIB) to which source code I have access to, have had their optimisation disabled and use the same threading mode as the main executable.
7) rebooted PC / VS

项目设置为 x64 调试,使用 SQLite3 LIB 和 DLL,OpenCL.lib

错误文件中的示例:

int a = 0;
a++;
=> a++; //debugger points at this line, though the value of 'a' is already equal to 2
a++;

一个文件有问题,而另一个文件可能没有问题。我没有发现受影响的文件与其内容之间存在任何相关性。

事实证明,我使用了中描述的最赞成的方法 堆栈帖子 "规范化"整个项目中的行尾。好像用。 在使用Visual Studio规范化行尾后,一切正常。

因此,对于遇到此问题的其他任何人,只需重新启用自动行尾修复,如果禁用,请转到 Tools=>Options=>Environment=>Documents 并启用"在加载时检查一致的行尾"。然后重新处理有问题的文件。

就我而言,我发现我实际上需要关闭项目,然后删除主exe项目文件夹和任何dll项目文件夹中的binobj文件夹。Visual Studio 将在下次打开解决方案时自动重新创建空binobj文件夹。此时,重新生成项目将解决此问题。