microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

includePath does not support ${fileDirname}

fr43nk opened this issue · comments

Environment

  • Windows 10
  • VS Code Version: 1.89.1
  • C/C++ Extension Version: 1.20.5
  • If using SSH remote, specify OS of remote machine: Linux Redhat

Bug Summary and Steps to Reproduce

Bug Summary:

Using file relative include definitions in settings file default.include does not respect this setting. it is getting ignored

Steps to reproduce:

Set the configuration of the default.include:

"C_Cpp.default.includePath": [
	"/project/folder2/subfolder/incs",
	"${fileDirname}/../h",
	"${fileDirname}/../../h",
	"${fileDirname}/../incs",
	"${fileDirname}/../../incs",
	"${fileDirname}/../../../incs",
	"${fileDirname}/../../../../incs",
	"/project/folder3/subfolder/incs",
	"/project/folder1/incs",
	"/project/folder4/incs/"
]

Only the absolute paths are part of the search path. All other entries, like "${fileDirname}/../../h" are ignored.

Expected behavior:

The search for the valid header files should start from the current open file and walk through all defined directories.

Configuration and Logs

"C_Cpp.default.includePath": [
	"/project/folder2/subfolder/incs",
	"${fileDirname}/../h",
	"${fileDirname}/../../h",
	"${fileDirname}/../incs",
	"${fileDirname}/../../incs",
	"${fileDirname}/../../../incs",
	"${fileDirname}/../../../../incs",
	"/project/folder3/subfolder/incs",
	"/project/folder1/incs",
	"/project/folder4/incs/"
]

Other Extensions

No response

Additional context

No response

${fileDirname} is not a stable path, so that variable is not supported in our configurations. Currently our extension only allows for per-file configurations via compile_commands.json and configurationProvider.

I believe this has been requested before, but I'm not sure that we kept that issue. We could maybe detect variables like ${fileDirname} and create a hidden configuration provider for them. I'll mark this as a feature request.

Ok, thanks.

just to explain a bit more: my first guess was, to write those include paths without the ${fileDirname} variable but that didn't work either. The goal is, that the search behavior is the same as the compiler does. There I have the same include structure. So in the end it would also be sufficient for me to just write ../../h. The extensions just needs to know that the start for all included header files is the current file.

If your files all have a common parent folder, you could do: /project/commonparent/**/h and /project/commonparent/**/incs and we'll figure out the include paths for you.

Hi,

thanks for the advice. But using /folder/**/h slows down my whole vscode. And nothing works.