C++ Edit and Continue in Visual Studio: When It Works, When It Doesn't
Youre mid-debug and want to change C-plus-plus code without restarting. Edit and Continue can deliver, but only if the debugger is paused, the module is marked editable, and the change avoids inlined or template functions.
24 Sept 2025, 10:50 UTC

Youre mid-debug, stepping through a C-plus-plus loop, and you realize the iteration limit is wrong. You tweak the source, press Continue, and expect the new count to take effect-only to watch the old behavior persist or the debugger complain. Edit and Continue promises zero-restart edits, but in practice it hinges on break mode, module editability, and compiler settings. If the conditions are met, you save a rebuild cycle; if not, a full restart is the only reliable path.
How Edit and Continue Works Under the Hood
When the Visual Studio debugger pauses execution at a breakpoint, it can re-compile the current function on the fly and patch the running process with the new machine code. This requires the project property Enable Edit and Continue to be turned on (Project Properties C/C++ Debugging). The compiler then marks the module as edit-eligible, typically with the /editandcontinue flag. Not every function qualifies: those that are inlined, that use certain compiler intrinsics, or whose change would alter a class layout are excluded. After you edit while the debugger is paused, VS prompts you to apply the change; once applied, pressing Continue resumes the program with the updated code.
Concrete Example: Changing a Loop Bound Mid-Debug
void process(int limit) { for (int i = 0; i < limit; ++i) { // work } }While debugging, you stop at the functions entry point. The debugger is paused. You change limit from 10 to 15 in the editor and click Apply. The build output may note that Edit and Continue is applying the modification. Pressing F5 continues execution, and the loop now iterates fifteen times without you having stopped and restarted the entire process. This flow works because the function is not inlined, the module is marked editable, and the change does not restructure any types.
When EnC Falls Short and How to Diagnose
Edit and Continue will silently skip edits that cross module boundaries, modify function signatures, or alter class hierarchies. The most common indicator is a warning in the Build Output window: Edit and Continue will not be applied. You can also watch the editor margin for a yellow banner or a small warning icon after attempting an edit. If the change is rejected, the debugger continues with the original binary, and the modification has no effect. For template-heavy code or lambdas, EnC is especially prone to failure; a full rebuild is then the safest route.
Quick Checklist for Reliable EnC Use
- Verify Enable Edit and Continue is checked in Project Properties C/C++ Debugging.
- Rebuild the project after toggling the setting; a plain build may not re-emit the edit-eligible metadata.
- Hit a breakpoint before applying any edit; EnC only works while the debugger is paused.
- After applying an edit, inspect the Build Output for warnings and the editor margin for acknowledgment icons.
- If your change touches inlined code, templates, lambdas, or cross-module boundaries, plan a full rebuild instead.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.