问题
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)
What I have already tried:
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
project is set to x64 Debug,takes use of SQLite3 LIB and DLL, OpenCL.lib
example in the faulty file:
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.
回答1:
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.
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.
来源:https://stackoverflow.com/questions/45886261/visual-studio-2017-c-pointing-a-wrong-line-while-stepping-through-the-code