c_cpp_properties.json vscode variables #12997
-
I am trying to use vscode variables within c_cpp_properties.json, and I do not understand the resolution strategy. All seems to be working like I expect; however, there is a contradiction.
I need / want a means to substitute a vscode variable that selects the current file. Not the currently open file within the editor. Vscode should provide such variables, but the variable reference only states the ${file_xx} variables resolving to the currently open editor file. What is the concrete implementation here as there is clearly a contradiction. I do not want to rely on something within c_cpp_properties.json if its just a fluke. If it is a fluke, I am going to put in a feature request at light speed, because it would be quite ridiculous to only provide ${file_xx} variable resolution with regards to the currently open editor. I (we) need a way to have variables resolve to the current file. How am I testing? This indicates that ${file_xx} used within c_cpp_properties.json is resolving to the directory of c_cpp_properties.json regardless of any open editor file. This is the desired behavior but is a contradiction to how its resolved within tasks.json and also what the documentation states. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
Hi @LostTime76, Thank you for your question. ${fileDirname} is not a defined "special" variable for The variable you seem to be describing that you want is Could you point to the documentation that you are referencing? I would guess you were referring to the VS Code documentation for Tasks which lists many variables. However, that is part of the core editor functionality and |
Beta Was this translation helpful? Give feedback.
-
The documentation I am referencing is here: Yes, I would like a 'stable' variable that does not change with the focused file. I would like to reference a path relative to the current file. In general, the user will be opening the workspace in the root folder, which will have .vscode folder, so ${workspaceFolder} would potentially work. However, it would be nice if there were variables that could just reference the current file / directory, so relative paths could be constructed without worrying about that. Maybe its not a huge deal... and I just have to tell people that the workspace needs to be opened on a specific folder containing the .vscode directory for everything to work. That way we can just use ${workspaceFolder}. |
Beta Was this translation helpful? Give feedback.
I think I talked myself out of the need for what I was looking for.. The contract is that the workspace must be opened with the proper path, otherwise it won't work.
My use case was perhaps generating / consuming the c_cpp_properties.json file using a custom tool and the tool being able to resolve a subset of the vscode variables. Since the tool would have no concept of ${worskspaceFolder}, a variable just resolving to the current path of the file directly would be better. I guess the tool could just resolve ${workspaceFolder} as the directory above the directory the c_cpp_properties.json is within as a special case.. because in order for even vscode to correctly work, the correct folder …