microsoft / microsoft/vscode-cpptools

Support ${relativeFileDirname} in c_cpp_properties.json

Open
#5,625 2 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Feature Request Feature: Configuration help wanted Language Service
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.