vscode-cpptools icon indicating copy to clipboard operation
vscode-cpptools copied to clipboard

Support '.' for includePath to reference the current TU's folder

Open magdumnikhil opened this issue 6 years ago • 5 comments

Type: LanguageService

Describe the bug Mentioning "-I." or "-I./" in compilerArgs should include the directory in which source file exists. Or "{fileDirname}" should be allowed in compilerArgs

  • OS and Version: Ubuntu 18.04 (64-bit)
  • VS Code Version: 1.41
  • C/C++ Extension Version: 0.26.2

I have a limited number of project-specific include directories(around 5-6) but many source directories (around 130-150). Total project files are around 1200

I want to include the path of the current source file in the includePath. But don't want it to be visible for the source files in other directories.

Recursive include will be overkill (considering project specific include directories only are 5-6 and total directories are ~150). If I update the includePath as lightbulb suggests for every source file it will be the same as recursive include.

To solve this, I tried mentioning compilerArgs as "-I." or "-I./" but it doesn't work. To confirm this I removed one of the include directories from includePath and added with "-I" option and got lots of error squiggles.

Mentioning "{fileDirname}" in the includePath also didn't help. C/C++ diagnostics shows that it is simply ignored. I suppose this happens because fileDirname applies to only files opened in vscode editor

Everything works fine if I convert the <include_file> to "include_file" but that won't be allowed because that would violate our coding conventions.

magdumnikhil avatar Jan 20 '20 07:01 magdumnikhil

Our extension processes #include "" as including the current directory (see https://gcc.gnu.org/onlinedocs/cpp/Search-Path.html), which is what you want, and using "." in includePath is causing just the root path to be used instead of the current directory and "-I." causes the root "/" path to be added, which seems like a bug.

sean-mcmanus avatar Jan 21 '20 21:01 sean-mcmanus

Thanks for confirming

magdumnikhil avatar Jan 25 '20 16:01 magdumnikhil

Since this bug doesn't have (m)any upvotes, I think it's very unlikely to be fixed in near future. Is there any workaround available, other than changing the <#include> to "#include"?

magdumnikhil avatar May 16 '20 19:05 magdumnikhil

I don't know a workaround. You may be able to implement a workaround or fix yourself and submit a PR (assuming it only requires TypeScript changes).

sean-mcmanus avatar May 18 '20 18:05 sean-mcmanus

This feature request is being closed due to insufficient upvotes. Please leave a 👍-upvote or 👎-downvote reaction on the issue to help us prioritize it. When enough upvotes are received, this issue will be eligible for our backlog.

github-actions[bot] avatar Mar 01 '25 11:03 github-actions[bot]