Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clangd doesn't work correctly when using the windows path separator (\) #92

Open
lh123 opened this issue Jul 13, 2019 · 3 comments
Open
Labels
bug Something isn't working help wanted Extra attention is needed upstream Bug originates with a library (e.g. clang) windows Mostly or entirely affects windows users

Comments

@lh123
Copy link

lh123 commented Jul 13, 2019

  • compile_commands.json
[
    {
        "directory": "G:\\VsCode\\STL",
        "command": "g++ -IG:\\VsCode\\STL\\include -o G:\\VsCode\\STL\\main.cpp -c G:\\VsCode\\STL\\main.cpp",
        "file": "G:\\VsCode\\STL\\main.cpp"
    }
]
  • log
I[11:37:12.422] Updating file g:\VsCode\STL\main.cpp with command 
[G:\VsCode\STL]
g++ --driver-mode=g++ -IG:VsCodeSTLinclude -o G:VsCodeSTLmain.cpp -c G:VsCodeSTLmain.cpp -fsyntax-only -resource-dir=D:\lib\clang\9.0.0\
@lh123
Copy link
Author

lh123 commented Nov 13, 2019

This problem caused by Triple.getEnvironment will return EnvironmentType::GNU when compiling clangd with MinGW-W64.

I think we shhould always use TokenizeWindowsCommandLine on Windows.

https://reviews.llvm.org/D70164?id=229011

@jsanchez19
Copy link

jsanchez19 commented Apr 23, 2021

I'm not familiar with Phabricator linked above. @lh123 has the fix been merged to a release? I'm on clangd 12.0.0 and still seeing the error Found unexpected ':' while scanning a plain scalar.

Is there a workaround for clangd 11 or 12?

EDIT: I should clarify, that this error I'm seeing is from the .clangd configuration file on the root directory of my project. Also, I'm on Windows 10 and I'm attempting to specify absolute paths to the toolchain directory as include paths, something like this:

.clangd

CompileFlags:
    Add: [
        -DSOME_SYMBOL=symbol_definition,
        -IC:\\path\\to\\compiler\\include
    ]

clangd error: Found unexpected ':' while scanning a plain scalar

@jsanchez19
Copy link

20 minutes later I realize that the error was due to having invalid YAML in the .clangd file. Surrounding the string that includes a colon in quotes resolves the issue. The .clangd file should look like this:

CompileFlags:
    Add: [
        -DSOME_SYMBOL=symbol_definition,
        "-IC:\\path\\to\\compiler\\include"
    ]

Sorry for the spam!

@kadircet kadircet added bug Something isn't working help wanted Extra attention is needed upstream Bug originates with a library (e.g. clang) windows Mostly or entirely affects windows users labels Dec 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed upstream Bug originates with a library (e.g. clang) windows Mostly or entirely affects windows users
Projects
None yet
Development

No branches or pull requests

3 participants