You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
How to pass VSC variables from c_cpp_properties.json to a Task? #742
Editing the make-file works for me, but the idea was to have a better integration. Leveraging Visual Studio Code interface to set parameters and retrieving those parameters from the makefile.
Is there something like export VARIABLE=VALUE available?
Which VS Code variables are you trying to read? Our extension does not set any environment variables. The contents of c_cpp_properties.json is not exported to the environment.
Rei Vilo (@rei-vilo) I assume you mean editing the "c_cpp_properties.json"? You shouldn't need to edit the makefile. Are you asking for cpptools to read the makefile and set the includePath and defines ourselves? Visual Studio 2017 does that for cmake, but we haven't implemented that yet. Theoretically, anyone could write a VS Code extension (or any script) that read makefiles or other build settings and read/modified our c_cpp_properties.json to correctly set the includePath/defines.
I need to get the "name" field so the main makefile can switch to the appropriate secondary one. Similarly, I’d like to add other fields and read them from the main makefile.
changed the title [-]How to get and read VS Code variables in a makefile?[/-][+]How to pass VSC variables from c_cpp_properties.json to a Task?[/+]on Oct 8, 2017
defines A list of preprocessor definitions for the IntelliSense engine to use while parsing files. Optionally, use = to set a value, for example VERSION=1.
Why not provide a similar logic for definitions tasks.json may read and use from c_cpp_properties.json?
Sorry, I should have resolved this issue a long time ago. VS Code added a feature that lets us do this and we added a command to get the active configuration name that you can use in your tasks.json.
Activity
sean-mcmanus commentedon May 22, 2017
You have to manually open the makefile and modify the includePath/defines settings in c_cpp_properties.json accordingly. Does that work for you?
rei-vilo commentedon May 22, 2017
Editing the make-file works for me, but the idea was to have a better integration. Leveraging Visual Studio Code interface to set parameters and retrieving those parameters from the makefile.
Is there something like
export VARIABLE=VALUEavailable?bobbrow commentedon May 22, 2017
Which VS Code variables are you trying to read? Our extension does not set any environment variables. The contents of c_cpp_properties.json is not exported to the environment.
[-]How to get and read VSC variables from makefile?[/-][+]How to get and read VS Code variables in a makefile?[/+]sean-mcmanus commentedon May 22, 2017
Rei Vilo (@rei-vilo) I assume you mean editing the "c_cpp_properties.json"? You shouldn't need to edit the makefile. Are you asking for cpptools to read the makefile and set the includePath and defines ourselves? Visual Studio 2017 does that for cmake, but we haven't implemented that yet. Theoretically, anyone could write a VS Code extension (or any script) that read makefiles or other build settings and read/modified our c_cpp_properties.json to correctly set the includePath/defines.
rei-vilo commentedon May 26, 2017
I've modified
c_cpp_properties.jsonto define different configurations with tool-chains and SDK instead of the OSes.I need to get the
"name"field so the main makefile can switch to the appropriate secondary one. Similarly, I’d like to add other fields and read them from the main makefile.rei-vilo commentedon Oct 8, 2017
Once a configuration is selected, e.g.
LaunchPad MSP432as per #742 (comment), how to get that value and pass it to the taskBuild, i.e.{{name}}?[-]How to get and read VS Code variables in a makefile?[/-][+]How to pass VSC variables from c_cpp_properties.json to a Task?[/+]rei-vilo commentedon Oct 8, 2017
Title How to pass VSC variables from c_cpp_properties.json to a Task? seems more appropriate.
sean-mcmanus commentedon Oct 9, 2017
Rei Vilo (@rei-vilo) There is currently no way to automatically get the value of the cpptools configuration name.
rei-vilo commentedon Oct 9, 2017
Ok, thanks, this is a show-stopper.
rei-vilo commentedon Mar 7, 2018
Chen Zhang (@czgtest)
Maybe you can help on this issue too.
bobbrow commentedon Mar 7, 2018
microsoft/vscode#43782
rei-vilo commentedon Feb 11, 2019
Bob Brown (@bobbrow) What do mean by more info needed?
bobbrow commentedon Feb 11, 2019
I removed that tag while doing some issue cleanup last week. It was set a long time ago before we understood the issue.
rei-vilo commentedon Aug 14, 2019
From c_cpp_properties.json reference | Configuration properties
Why not provide a similar logic for definitions tasks.json may read and use from c_cpp_properties.json?
Integrate with External Tools via Tasks | Variable substitution details Predefined variables, Environment variables and Configuration variables, but is mum about variables defined in c_cpp_properties.json
configurations.sean-mcmanus commentedon Aug 15, 2019
VS Code itself controls the execution of tasks.json and there's no way for us to get them to use c_cpp_properties.json info.
bobbrow commentedon Oct 17, 2019
Sorry, I should have resolved this issue a long time ago. VS Code added a feature that lets us do this and we added a command to get the active configuration name that you can use in your tasks.json.
${command:cpptools.activeConfigName}rei-vilo commentedon Oct 18, 2019
Thank you!
rei-vilo commentedon Oct 19, 2019
Bob Brown (@bobbrow) It works fine.
Where can I find the documentation related to this feature? Pages Customizing default settings and c_cpp_properties.json reference for the C++ extension, and page Integrate with External Tools via Tasks for Tasks, do not mention
cpptools.activeConfigName.Thank you!