microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.52k stars 1.55k forks source link

Extension does not correctly handle WSL symlinks #2140

Open schwarzichet opened 6 years ago

schwarzichet commented 6 years ago

Type: LanguageService

Describe the bug

To Reproduce Steps to reproduce the behavior: c_cpp_prperties.json

{
    "configurations": [
        {
            "name": "WSL",
            "intelliSenseMode": "clang-x64",
            "compilerPath": "/usr/bin/gcc",
            "includePath": [
                "${workspaceFolder}",
                "/mnt/c/libraries/lib1/include",
                "C:/libraries/lib2/include"
            ],
            "defines": [],
            "browse": {
                "path": [
                    "${workspaceFolder}",
                    "/mnt/c/libraries"
                ],
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": ""
            },
            "cStandard": "c11",
            "cppStandard": "c++17"
        }
    ],
    "version": 4
}

edit an C/C++ source code file and try to type this

#include <llvm/IR/Module.h>

Expected behavior show no error read lines and make correct intellisense

Screenshots

default

Additional context it seems that the extension do find the LLVM folder but somehow it cannot recognize it. I tried to make a soft link named "llvm" for "llvm-6.0" in /usr/include/ but it is useless.

bobbrow commented 6 years ago

Where does llvm live on your PC? Do you have a C:\libraries folder on your PC, or is that configuration just the value copied from the documentation? You should add the path to the llvm folder in your configuration browse.path and includePath if you want it to show up in IntelliSense.

schwarzichet commented 6 years ago

well, I just figured out that "/mnt/c/libraries/lib1/include" means you should replace it with your library path. Now it works with such a configuration

{
    "configurations": [
        {
            "name": "WSL",
            "intelliSenseMode": "clang-x64",
            "compilerPath": "/usr/bin/gcc",
            "includePath": [
                "${workspaceFolder}",
                "/usr/include/llvm-6.0",
                "/usr/include/llvm-c-6.0"
            ],
            "defines": [],
            "browse": {
                "path": [
                    "${workspaceFolder}",
                    "/usr/include/llvm-6.0",
                    "/usr/include/llvm-c-6.0"
                ],
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": ""
            },
            "cStandard": "c11",
            "cppStandard": "c++17"
        }
    ],
    "version": 4
}

But I wonder why the soft link fails. I do make the soft link but it fails when I set the c_cpp_properties.json as

{
    "configurations": [
        {
            "name": "WSL",
            "intelliSenseMode": "clang-x64",
            "compilerPath": "/usr/bin/gcc",
            "includePath": [
                "${workspaceFolder}",
                "/usr/include/llvm",
                "/usr/include/llvm-c"
            ],
            "defines": [],
            "browse": {
                "path": [
                    "${workspaceFolder}",
                    "/usr/include/llvm",
                    "/usr/include/llvm-c"
                ],
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": ""
            },
            "cStandard": "c11",
            "cppStandard": "c++17"
        }
    ],
    "version": 4
}

Does it have something to do with https://github.com/Microsoft/WSL/issues/1475

bobbrow commented 6 years ago

It could. But we haven't done any testing of WSL symlinks in the Windows environment (where VS Code runs). We can use this issue to track that.

sean-mcmanus commented 6 years ago

Oh, this is a bug with #include completion not treating symlinks as directories. We correctly resolve the symlinks in the includePath so the header is found by IntelliSense (no green squiggle), right?