microsoft / microsoft/vscode-cpptools
Support ${relativeFileDirname} in c_cpp_properties.json
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 6.2k
- Forks
- 1.7k
- Avg merge
- 14h 46m
- Merged PRs (30d)
- 61
Description
Type: LanguageService
Describe the bug
- OS and Version: Windows 10
- VS Code Version: 1.45.1
- C/C++ Extension Version: 0.28.2
- Other extensions you installed (and if the issue persists after disabling them): N/A
- Does this issue involve using SSH remote to run the extension on a remote machine?: No
VSCode supports ${relativeFileDirname} in launch.json and tasks.json. See here. I would like to have support for this variable in c_cpp_properties.json. I have a module testing framework that generates mocked functions and places them in mock_defaults.h. Each test has its own version of this header. When the test is open in the editor cpp_tools should grab ${relativeFileDirname} and use it for that translation units include paths.
Ex c_cpp_properties.json:
{
"configurations": [
{
"defines": [
"${default}"
],
"includePath": [
"${default}",
"${workspaceFolder:System Code}/bin/mod/${relativeFileDirname}"
],
"intelliSenseMode": "msvc-x64",
"name": "Win32"
}
],
"version": 4
}
Expected behavior
The above config should allow each translation unit (i.e. module test in my case) to use a path unique to itself.
For expample,
${workspaceFolder} = c/code/dev
${fileDirname} = c/code/dev/tests/path/to/test
${relativeFileDirname} = tests/path/to/test
final include path = c/code/dev/bin/mod/tests/path/to/test
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the c_cpp_properties.json variable expansion behavior and compare it with the documented variable support in launch.json and tasks.json. Use the example configuration and path values in this issue to verify that ${relativeFileDirname} resolves per translation unit and produces the expected include path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100