Thanks for reaching out. Here’s a breakdown for their roles:
1. Settings.json
· Used by the C/C++ extension in VS code.
· The setting “C_Cpp.default.compilerPath” (or “C_Cpp.default.intelliSenseMode”) tells the IntelliSense engine which compiler to reference.
· This helps VS Code provide code completion, error squiggles, and IntelliSense consistent with the compiler you’re using.
· It does not actually compile or run the code it’s mainly for editing experience.
2. Tasks.json
· Defines how your code is built when you run Ctrl+Shift+B(build task).
· Specifies which compiler executable (e.g., gcc, clang, cl.exe) to call, along with arguments.
3. Launch.json
· Defines how your program is debugged.
· Referring to the compiled binary(output from tasks.json) and configures debugger settings.
· It does not directly specify the compiler path but indirectly depend on the build task that used the compiler.
How the compiler path is determined automatically
· When you install the C / C++ extension, VS code tries to detect available compilers (gcc, clang, cl.exe) from your system PATH.
· The first detected compiler may be auto-filled in tasks.json and launch.json.
· If multiple compilers are found, you can configure “C_Cpp.default.compilerPath” in settings.json to guide the IntelliSense and then manually generate/update tasks via “C/C++: edit configurations(UI)”.
Prompting for compiler each time
· Remove
“C_Cpp.default.compilerPtah” from settings.json, so VS Code asks when IntelliSense needs it.
· Or define multiple tasks in
Tasks.json(e.g., one for GCC, one for Clag), then choose which task to run using “Run Build Task”.
· Use CMake tools extension if you want automatic multi-compiler management.
So in short:
Settings.json -> IntelliSense compiler reference
Tasks.json -> Actual compilation task
Launch.json -> Debugging setup, tied to the build task
You can also refer to these sites:
· C++ extension settings reference
· Configure C/C++ IntelliSense
· Using C++ on Linux in VS Code
· Configure VS Code for Microsoft C++
Let me know if you need any further help with this. We'll be happy to assist.
If you find this helpful, please mark this as answered.
Answer from Adiba Khan on learn.microsoft.comI followed what is said on this blog post, it takes so much time to run(or build) and sometimes just doesn't.
i've been using CodeBlocks before but didn't get comfortable with it i just don't like, it would be great if i can use VSC.
Edit: i use Windows.