Vscode-cpptools: Multi-Root workspaces, where some roots are children of other roots

Created on 15 Feb 2019  路  4Comments  路  Source: microsoft/vscode-cpptools

Type: LanguageService

Describe the bug

  • OS and Version: Windows 10
  • VS Code Version: 1.31.1
  • C/C++ Extension Version: 0.22.0

I've kind of raised this issue before, but didn't get a proper answer -- and previously things seemed to work, so I just lived with it. Imagine this folder structure (on-disk):

my_project/
|- subproject_a/
|  |- some_file.cpp
|
|- subproject_b/
|  |- some_other_file.cpp
|
|- makefile
|- other_important_file

I was previously informed that multi-root workspaces do not properly support the case where some roots (ie. subproject_a and subproject_b) are children of another root (ie. my_project). However, given that I need to be able to access the files in the root directory, what are my options?

I would just use a single-root workspace with the top-level folder as my root, but each sub-project requires its own c_cpp_properties.json due to conflicting build requirements.

Curiously, things seemed (seemed) to work just fine, until I recently added another workspace; suddenly, the extension refused to give any error messages and refused to provide sensible autocomplete suggestions -- even basic stuff like missing semicolons don't do anything. The output log has shown nothing out of the ordinary:

IntelliSense Engine = Default.
Autocomplete is enabled.
Error squiggles are enabled.
File exclude: **/.git
File exclude: **/.svn
File exclude: **/.hg
File exclude: **/CVS
File exclude: **/.DS_Store
File exclude: **/*.c.d
File exclude: **/*.cpp.d
File exclude: **/*.o
File exclude: **/*.o.m
File exclude: **/.vscode
Search exclude: **/node_modules
Search exclude: **/bower_components
Search exclude: **/.vscode
Failed to query default include paths and defines for d:\Projects\nx/build/toolchain/bin/x86_64-orionx-g++. WSL not detected
Code browsing service initialized
Failed to query default include paths and defines for d:\Projects\nx/build/toolchain/bin/x86_64-orionx-g++. WSL not detected
  Folder: D:/Programs/archlinux/rootfs/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.1/include/ will be indexed
  Folder: D:/Programs/archlinux/rootfs/usr/local/include/ will be indexed
  Folder: D:/Programs/archlinux/rootfs/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.1/include-fixed/ will be indexed
  Folder: D:/Programs/archlinux/rootfs/usr/include/ will be indexed
  Folder: D:/Projects/nx/libs/libnxpc/ will be indexed
Populate include completion cache.
Discovering files...
  Processing folder (recursive): D:/Programs/archlinux/rootfs/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.1/include/
  Processing folder (recursive): D:/Programs/archlinux/rootfs/usr/local/include/
  Processing folder (recursive): D:/Programs/archlinux/rootfs/usr/lib/gcc/x86_64-pc-linux-gnu/8.2.1/include-fixed/
  Processing folder (recursive): D:/Programs/archlinux/rootfs/usr/include/
  Processing folder (recursive): D:/Projects/nx/libs/libnxpc/
  Discovering files: 4814 file(s) processed
  0 file(s) removed from database
Done discovering files.
Parsing remaining files...
  Parsing: 0 files(s) processed
Done parsing remaining files.

EDIT: after some experimentation, putting the root workspace as the last one in the code-workspace file allows the extension to work again. not entirely sure why.

Multiroot Language Service bug fixed (release pending)

All 4 comments

For what it's worth putting the root workspace as the last one also worked for me

Our latest Insiders release has a new multi-root implementation (which fixes this bug): https://github.com/microsoft/vscode-cpptools/releases/tag/0.27.0-insiders. Please let us know if you find any multi-root-related bugs or regressions so we can prioritize fixing those for 0.27.0.

Hi Sean, thanks for the update! I'll give it a try when I have the time (:

Alright, from my preliminary testing it looks like everything works like it should and the definitions etc. are updating properly.

thanks so much for fixing this (:

Was this page helpful?
0 / 5 - 0 ratings