Search code examples
visual-studiovisual-studio-2015

A copy of a.cpp was found in somepath, but the current source code is different from the version built into somepath


This warning pops out in such scenario:

  • Start debugging (F5) a C++ program
  • Edit some code while debugging (the program hits a breakpoint and then pauses for example) [#]
  • Stop debugging (Shift+F5) the program
  • Start debugging (F5) again [*] -> WARNING: but the current source code is different from the version

Actually in step [*], I would like to debug the code with modifications made in step [#]. However, Visual Studio is actually debugging the code without modifications made in step [#] and thus warns me about that.

I have to clean the project before step [*] to make Visual Studio be aware of my modifications made in step [#]. How could I make Visual Studio always debug my up-to-date source files?

Extra information: It's "Always Build" and the "Build" box is checked in Configuration Manager. Besides, in step [*], even I manually trigger "Build" (Ctrl+Shift+B), it says that my project is up-to-date. Actually my my project is out-of-date both in "Start Without Debugging" and "Start Debugging". I have to clean the project to make my project up-to-date.

Video attached (2 mins), starting from "new project": https://www.youtube.com/watch?v=0y9RljtS28k


Solution

  • I have figured it out by myself that it is a feature called Edit and Continue.

    It's under Tools - Options - Debugging - General - Enable Edit and Continue

    To apply code changes explicitly, on the Debug menu, choose Apply Code Changes [1].

    [1] https://msdn.microsoft.com/en-us/library/esaeyddf.aspx#bkmk_how_to_apply_code_changes_explicitly