Visual Studio 2017,C ++,单步执行代码时指向错误的行 [英] Visual Studio 2017, C++, pointing a wrong line while stepping through the code

查看:48
本文介绍了Visual Studio 2017,C ++,单步执行代码时指向错误的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在某些文件中,调试器在单步执行代码时指向错误的行.确切地说,它只用一条线(总是)关闭

In some of the files, debugger is pointing at the wrong line, while stepping through the code. To be precise, it is off by exectly one line (always)

我已经已经尝试过的内容:

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

project is set to x64 Debug,takes use of SQLite3 LIB and DLL, OpenCL.lib

错误文件中的示例:

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

一个文件有问题,而另一个文件可能没有问题.我尚未在受影响的文件及其内容之间找到任何关联.

One file has the issue, while another might not have it. I haven't found any corelation between affected files and their content.

推荐答案

结果证明,我使用的是最受好评的方法,堆栈帖子以规范化"整个项目中的行尾.似乎它没有成功.在使用Visual Studio对行尾进行归一化之后,一切正常.

Turns out I've used the most upvoted method described in stack post to 'normalize' line endings in the entire project. Seems like it did not work. After normalising line endings with Visual Studio everything works fine.

因此,对于任何其他有此问题的人,只需转到Tools => Options => Environment => Documents并启用检查加载时一致的行尾",即可重新启用自动行尾修复(如果禁用).然后重新记录有问题的文件.

So for anyone else with this problem, just re-enable automatic line-ending fix-up ,if disabled, by going to Tools=>Options=>Environment=>Documents and enable 'check for consistient line endings on load'. Then repen problematic file.

这篇关于Visual Studio 2017,C ++,单步执行代码时指向错误的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆