Reputation: 343
I am a newbie in cpp programming and use visual studio code, I don't understand what is the difference between Ctrl + Alt + N(To run code) and Ctrl + F5(Run without Debugging).
Upvotes: 13
Views: 34785
Reputation: 67
This is an open issue on GitHub: https://github.com/microsoft/vscode-cpptools/issues/1201
"The C++ extension does not include a build system, so only simple compilation of single files is supported. Anything more complicated is generally done in the terminal, with tasks.json
, or with a build system extension like CMake Tools or Makefile Tools. Using one of those options will get you debug mode vs. high performance mode. This issue is about adding support to run your built executables directly in the terminal instead of having them pass through the debugger interface - even though they are not being debugged."
Upvotes: 0
Reputation: 3305
Ctrl+Alt+N (Run Code) is a shortcut provided by the "Code Runner" extension you've installed. It runs the code without debugging.
Ctrl+F5 (Debug: Start without Debugging) is a VS Code default shortcut. Despite its name, it actually runs the C++ code with debugging. This is because according to the VS Code docs:
Tip: The Run action is always available, but not all debugger extensions support 'Run'. In this case, 'Run' will be the same as 'Debug'.
Apparently the C/C++ extension does not support "Run", so Ctrl + F5
will launch a debug session instead.
Upvotes: 10
Reputation: 9970
It's probably worth noting since this is tagged c++
that CTRL-F5
, run without debugging actually runs with debugging as of August 23rd 2021. That's in-spec for the app according to these docs, "Tip: The Run action is always available, but not all debugger extensions support 'Run'. In this case, 'Run' will be the same as 'Debug'."
SHIFT-F5
from the standard C++ extension, by contrast, does run without debugging, but runs a target set by its own mechanism, not the current launch configuration used by F5
and CTRL-F5
. Since it bypasses the launch.json
launch configurations, it does not let you change the location of the current working directory for your app or pass-in command line arguments to it.
Upvotes: 14