Setting compilerArgs when generating tasks.json file for compiling #7851
-
Hello, I have a scenario where I will have many students creating several C++ projects in VS-Code. To streamline the experience, I am trying to set default flags for `
` That seems to do the trick. Now, I noticed that the configuration variable ` ` I will be thankful for any tips or ideas on how the |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 4 replies
-
You shouldn't probably be modifiying the javascript. You could git clone our repo and put a breakpoint at https://github.com/microsoft/vscode-cpptools/blob/main/Extension/src/LanguageServer/cppBuildTaskProvider.ts#L169 to see what is going on -- looks like it's just "undefined". In general, the cppbuild feature (which controls building) wasn't designed to inherit from c_cpp_properties.json or the C_Cpp.default settings (which just controls IntelliSense)....maybe we could accept change to the design, not sure. If you want to give your students a really streamlined experience, I would recommend setting the configurationProvider and using the CMake Tools or Makefile Tools extensions or compileCommands, i.e. have the build system configure IntelliSense instead of the other way around. |
Beta Was this translation helpful? Give feedback.
-
Thank you for your quick response. Maybe having a configuration variable to set up compiler args would be a good feature/idea. At least by default, I think it would be better to keep things consistent by using the same settings as IntelliSense, if the compiler args are undefined. In addition, it would be nice to have a comment in the generated "tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++ build active file",
"command": "/apps/gnu/8.4.0/bin/g++",
// Overrides from settings.json
"args": [ "-g", "-Wall", "-std=c++17", "-fsanitize=address",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
], |
Beta Was this translation helpful? Give feedback.
-
I am looking into |
Beta Was this translation helpful? Give feedback.
You shouldn't probably be modifiying the javascript. You could git clone our repo and put a breakpoint at https://github.com/microsoft/vscode-cpptools/blob/main/Extension/src/LanguageServer/cppBuildTaskProvider.ts#L169 to see what is going on -- looks like it's just "undefined". In general, the cppbuild feature (which controls building) wasn't designed to inherit from c_cpp_properties.json or the C_Cpp.default settings (which just controls IntelliSense)....maybe we could accept change to the design, not sure.
If you want to give your students a really streamlined experience, I would recommend setting the configurationProvider and using the CMake Tools or Makefile Tools extensions or compi…