clangd / vscode-clangd

Visual Studio Code extension for clangd
https://marketplace.visualstudio.com/items?itemName=llvm-vs-code-extensions.vscode-clangd
MIT License
638 stars 113 forks source link

Header File Inclusion Error in C++ files with `vscode-clangd` extension #553

Open niamotullah opened 11 months ago

niamotullah commented 11 months ago

Issue

After installing this extension VSCode editor shows error on C++ file saying 'iostream' file not foundclang(pp_file_not_found). But it compiles without any problem. Screenshot from 2023-11-22 00-23-30

Temp Solution

After googling i found lots of people also facing the same problem. But none of those mentioned soutions worked for me except one from this post stackoverflow.com, Where installing libstdc++-12-dev solved the missing header problem in C++ files:

sudo apt install libstdc++-12-dev

Question

Logs

clangd "Output" window logs with --log=verbose:

I[23:42:19.924] clangd version 16.0.2 (https://github.com/llvm/llvm-project 18ddebe1a1a9bde349441631365f0472e9693520)
I[23:42:19.924] Features: linux+grpc
I[23:42:19.924] PID: 50049
I[23:42:19.924] Working directory: /mnt/part7/code/cpp-learn
I[23:42:19.924] argv[0]: /home/niamotullah/.config/Code/User/globalStorage/llvm-vs-code-extensions.vscode-clangd/install/16.0.2/clangd_16.0.2/bin/clangd
I[23:42:19.924] argv[1]: --log=verbose
V[23:42:19.924] User config file is /home/niamotullah/.config/clangd/config.yaml
I[23:42:19.924] Starting LSP over stdin/stdout
V[23:42:19.925] <<< {"id":0,"jsonrpc":"2.0","method":"initialize","params":{"capabilities":{"general":{"markdown":{"parser":"marked","version":"1.1.0"},"positionEncodings":["utf-16"],"regularExpressions":{"engine":"ECMAScript","version":"ES2020"},"staleRequestSupport":{"cancel":true,"retryOnContentModified":["textDocument/semanticTokens/full","textDocument/semanticTokens/range","textDocument/semanticTokens/full/delta"]}},"notebookDocument":{"synchronization":{"dynamicRegistration":true,"executionSummarySupport":true}},"textDocument":{"callHierarchy":{"dynamicRegistration":true},"codeAction":{"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}},"dataSupport":true,"disabledSupport":true,"dynamicRegistration":true,"honorsChangeAnnotations":false,"isPreferredSupport":true,"resolveSupport":{"properties":["edit"]}},"codeLens":{"dynamicRegistration":true},"colorProvider":{"dynamicRegistration":true},"completion":{"completionItem":{"commitCharactersSupport":true,"deprecatedSupport":true,"documentationFormat":["markdown","plaintext"],"insertReplaceSupport":true,"insertTextModeSupport":{"valueSet":[1,2]},"labelDetailsSupport":true,"preselectSupport":true,"resolveSupport":{"properties":["documentation","detail","additionalTextEdits"]},"snippetSupport":true,"tagSupport":{"valueSet":[1]}},"completionItemKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25]},"completionList":{"itemDefaults":["commitCharacters","editRange","insertTextFormat","insertTextMode"]},"contextSupport":true,"dynamicRegistration":true,"editsNearCursor":true,"insertTextMode":2},"declaration":{"dynamicRegistration":true,"linkSupport":true},"definition":{"dynamicRegistration":true,"linkSupport":true},"diagnostic":{"dynamicRegistration":true,"relatedDocumentSupport":false},"documentHighlight":{"dynamicRegistration":true},"documentLink":{"dynamicRegistration":true,"tooltipSupport":true},"documentSymbol":{"dynamicRegistration":true,"hierarchicalDocumentSymbolSupport":true,"labelSupport":true,"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]},"tagSupport":{"valueSet":[1]}},"foldingRange":{"dynamicRegistration":true,"foldingRange":{"collapsedText":false},"foldingRangeKind":{"valueSet":["comment","imports","region"]},"lineFoldingOnly":true,"rangeLimit":5000},"formatting":{"dynamicRegistration":true},"hover":{"contentFormat":["markdown","plaintext"],"dynamicRegistration":true},"implementation":{"dynamicRegistration":true,"linkSupport":true},"inlayHint":{"dynamicRegistration":true,"resolveSupport":{"properties":["tooltip","textEdits","label.tooltip","label.location","label.command"]}},"inlineValue":{"dynamicRegistration":true},"linkedEditingRange":{"dynamicRegistration":true},"onTypeFormatting":{"dynamicRegistration":true},"publishDiagnostics":{"codeDescriptionSupport":true,"dataSupport":true,"relatedInformation":true,"tagSupport":{"valueSet":[1,2]},"versionSupport":false},"rangeFormatting":{"dynamicRegistration":true},"references":{"dynamicRegistration":true},"rename":{"dynamicRegistration":true,"honorsChangeAnnotations":true,"prepareSupport":true,"prepareSupportDefaultBehavior":1},"selectionRange":{"dynamicRegistration":true},"semanticTokens":{"augmentsSyntaxTokens":true,"dynamicRegistration":true,"formats":["relative"],"multilineTokenSupport":false,"overlappingTokenSupport":false,"requests":{"full":{"delta":true},"range":true},"serverCancelSupport":true,"tokenModifiers":["declaration","definition","readonly","static","deprecated","abstract","async","modification","documentation","defaultLibrary"],"tokenTypes":["namespace","type","class","enum","interface","struct","typeParameter","parameter","variable","property","enumMember","event","function","method","macro","keyword","modifier","comment","string","number","regexp","operator","decorator"]},"signatureHelp":{"contextSupport":true,"dynamicRegistration":true,"signatureInformation":{"activeParameterSupport":true,"documentationFormat":["markdown","plaintext"],"parameterInformation":{"labelOffsetSupport":true}}},"synchronization":{"didSave":true,"dynamicRegistration":true,"willSave":true,"willSaveWaitUntil":true},"typeDefinition":{"dynamicRegistration":true,"linkSupport":true},"typeHierarchy":{"dynamicRegistration":true}},"window":{"showDocument":{"support":true},"showMessage":{"messageActionItem":{"additionalPropertiesSupport":true}},"workDoneProgress":true},"workspace":{"applyEdit":true,"codeLens":{"refreshSupport":true},"configuration":true,"diagnostics":{"refreshSupport":true},"didChangeConfiguration":{"dynamicRegistration":true},"didChangeWatchedFiles":{"dynamicRegistration":true,"relativePatternSupport":true},"executeCommand":{"dynamicRegistration":true},"fileOperations":{"didCreate":true,"didDelete":true,"didRename":true,"dynamicRegistration":true,"willCreate":true,"willDelete":true,"willRename":true},"inlayHint":{"refreshSupport":true},"inlineValue":{"refreshSupport":true},"semanticTokens":{"refreshSupport":true},"symbol":{"dynamicRegistration":true,"resolveSupport":{"properties":["location.range"]},"symbolKind":{"valueSet":[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]},"tagSupport":{"valueSet":[1]}},"workspaceEdit":{"changeAnnotationSupport":{"groupsOnLabel":true},"documentChanges":true,"failureHandling":"textOnlyTransactional","normalizesLineEndings":true,"resourceOperations":["create","rename","delete"]},"workspaceFolders":true}},"clientInfo":{"name":"Visual Studio Code","version":"1.84.2"},"initializationOptions":{"clangdFileStatus":true,"fallbackFlags":[]},"locale":"en-us","processId":49545,"rootPath":"/mnt/part7/code/cpp-learn","rootUri":"file:///mnt/part7/code/cpp-learn","trace":"off","workspaceFolders":[{"name":"cpp-learn","uri":"file:///mnt/part7/code/cpp-learn"}]}}

I[23:42:19.925] <-- initialize(0)
I[23:42:19.926] --> reply:initialize(0) 0 ms
V[23:42:19.926] >>> {"id":0,"jsonrpc":"2.0","result":{"capabilities":{"astProvider":true,"callHierarchyProvider":true,"clangdInlayHintsProvider":true,"codeActionProvider":{"codeActionKinds":["quickfix","refactor","info"]},"compilationDatabase":{"automaticReload":true},"completionProvider":{"resolveProvider":false,"triggerCharacters":[".","<",">",":","\"","/","*"]},"declarationProvider":true,"definitionProvider":true,"documentFormattingProvider":true,"documentHighlightProvider":true,"documentLinkProvider":{"resolveProvider":false},"documentOnTypeFormattingProvider":{"firstTriggerCharacter":"\n","moreTriggerCharacter":[]},"documentRangeFormattingProvider":true,"documentSymbolProvider":true,"executeCommandProvider":{"commands":["clangd.applyFix","clangd.applyTweak"]},"foldingRangeProvider":true,"hoverProvider":true,"implementationProvider":true,"inlayHintProvider":true,"memoryUsageProvider":true,"referencesProvider":true,"renameProvider":{"prepareProvider":true},"selectionRangeProvider":true,"semanticTokensProvider":{"full":{"delta":true},"legend":{"tokenModifiers":["declaration","definition","deprecated","deduced","readonly","static","abstract","virtual","dependentName","defaultLibrary","usedAsMutableReference","usedAsMutablePointer","constructorOrDestructor","userDefined","functionScope","classScope","fileScope","globalScope"],"tokenTypes":["variable","variable","parameter","function","method","function","property","variable","class","interface","enum","enumMember","type","type","unknown","namespace","typeParameter","concept","type","macro","modifier","operator","comment"]},"range":false},"signatureHelpProvider":{"triggerCharacters":["(",")","{","}","<",">",","]},"standardTypeHierarchyProvider":true,"textDocumentSync":{"change":2,"openClose":true,"save":true},"typeDefinitionProvider":true,"typeHierarchyProvider":true,"workspaceSymbolProvider":true},"serverInfo":{"name":"clangd","version":"clangd version 16.0.2 (https://github.com/llvm/llvm-project 18ddebe1a1a9bde349441631365f0472e9693520) linux+grpc x86_64-unknown-linux-gnu"}}}

V[23:42:19.939] <<< {"jsonrpc":"2.0","method":"initialized","params":{}}

I[23:42:19.939] <-- initialized
V[23:42:19.943] <<< {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"cpp","text":"#include <iostream>\nusing namespace std;\n\nint main() {\n    cout << \"Hello\" << endl;\n\n    return 0;\n}","uri":"file:///mnt/part7/code/cpp-learn/hello.cpp","version":1}}}

I[23:42:19.943] <-- textDocument/didOpen
V[23:42:19.944] config note at /home/niamotullah/.config/clangd/config.yaml:2:0: Parsing config fragment
V[23:42:19.944] config note at /home/niamotullah/.config/clangd/config.yaml:1:0: Parsed 1 fragments from file
V[23:42:19.944] Config fragment: compiling /home/niamotullah/.config/clangd/config.yaml:2 -> 0x00007F0980001400 (trusted=true)
I[23:42:19.944] --> textDocument/publishDiagnostics
V[23:42:19.944] >>> {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[],"uri":"file:///home/niamotullah/.config/clangd/config.yaml"}}

I[23:42:19.944] Failed to find compilation database for /mnt/part7/code/cpp-learn/hello.cpp
I[23:42:19.944] ASTWorker building file /mnt/part7/code/cpp-learn/hello.cpp version 1 with command clangd fallback
[/mnt/part7/code/cpp-learn]
/usr/lib/llvm-14/bin/clang -resource-dir=/home/niamotullah/.config/Code/User/globalStorage/llvm-vs-code-extensions.vscode-clangd/install/16.0.2/clangd_16.0.2/lib/clang/16 -- /mnt/part7/code/cpp-learn/hello.cpp
V[23:42:19.945] Driver produced command: cc1 -cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name hello.cpp -mrelocation-model pic -pic-level 2 -pic-is-pie -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -mllvm -treat-scalable-fixed-error-as-warning -debugger-tuning=gdb -fcoverage-compilation-dir=/mnt/part7/code/cpp-learn -resource-dir /home/niamotullah/.config/Code/User/globalStorage/llvm-vs-code-extensions.vscode-clangd/install/16.0.2/clangd_16.0.2/lib/clang/16 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++ -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/x86_64-linux-gnu -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/backward -internal-isystem /home/niamotullah/.config/Code/User/globalStorage/llvm-vs-code-extensions.vscode-clangd/install/16.0.2/clangd_16.0.2/lib/clang/16/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdeprecated-macro -fdebug-compilation-dir=/mnt/part7/code/cpp-learn -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -no-round-trip-args -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -x c++ /mnt/part7/code/cpp-learn/hello.cpp
I[23:42:19.945] --> textDocument/clangd.fileStatus
V[23:42:19.945] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"parsing includes, running Update","uri":"file:///mnt/part7/code/cpp-learn/hello.cpp"}}

V[23:42:19.945] Building first preamble for /mnt/part7/code/cpp-learn/hello.cpp version 1
V[23:42:19.951] indexed preamble AST for /mnt/part7/code/cpp-learn/hello.cpp version 1:
  symbol slab: 0 symbols, 120 bytes
  ref slab: 0 symbols, 0 refs, 128 bytes
  relations slab: 0 relations, 24 bytes
I[23:42:19.952] Built preamble of size 217084 for file /mnt/part7/code/cpp-learn/hello.cpp version 1 in 0.01 seconds
I[23:42:19.952] --> workspace/semanticTokens/refresh(0)
I[23:42:19.952] --> textDocument/clangd.fileStatus
V[23:42:19.952] >>> {"id":0,"jsonrpc":"2.0","method":"workspace/semanticTokens/refresh","params":null}

V[23:42:19.952] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"parsing includes, running Build AST","uri":"file:///mnt/part7/code/cpp-learn/hello.cpp"}}

V[23:42:19.952] <<< {"id":0,"jsonrpc":"2.0","result":null}

I[23:42:19.952] <-- reply(0)
V[23:42:19.956] Trying to fix unresolved name "cout" in scopes: [, std::]
V[23:42:19.956] Trying to fix unresolved name "endl" in scopes: [, std::]
V[23:42:19.956] indexed file AST for /mnt/part7/code/cpp-learn/hello.cpp version 1:
  symbol slab: 1 symbols, 4448 bytes
  ref slab: 1 symbols, 1 refs, 4248 bytes
  relations slab: 0 relations, 24 bytes
V[23:42:19.956] Build dynamic index for main-file symbols with estimated memory usage of 11520 bytes
I[23:42:19.956] --> textDocument/publishDiagnostics
V[23:42:19.956] >>> {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[{"code":"pp_file_not_found","message":"'iostream' file not found","range":{"end":{"character":19,"line":0},"start":{"character":9,"line":0}},"relatedInformation":[],"severity":1,"source":"clang"},{"code":"ext_using_undefined_std","message":"Using directive refers to implicitly-defined namespace 'std'","range":{"end":{"character":19,"line":1},"start":{"character":16,"line":1}},"relatedInformation":[],"severity":2,"source":"clang"},{"code":"undeclared_var_use","message":"Use of undeclared identifier 'cout'","range":{"end":{"character":8,"line":4},"start":{"character":4,"line":4}},"relatedInformation":[],"severity":1,"source":"clang"},{"code":"undeclared_var_use","message":"Use of undeclared identifier 'endl'","range":{"end":{"character":27,"line":4},"start":{"character":23,"line":4}},"relatedInformation":[],"severity":1,"source":"clang"}],"uri":"file:///mnt/part7/code/cpp-learn/hello.cpp","version":1}}

I[23:42:19.956] --> textDocument/clangd.fileStatus
V[23:42:19.956] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"idle","uri":"file:///mnt/part7/code/cpp-learn/hello.cpp"}}

V[23:42:20.036] <<< {"id":1,"jsonrpc":"2.0","method":"textDocument/documentLink","params":{"textDocument":{"uri":"file:///mnt/part7/code/cpp-learn/hello.cpp"}}}

I[23:42:20.036] <-- textDocument/documentLink(1)
V[23:42:20.036] ASTWorker running DocumentLinks on version 1 of /mnt/part7/code/cpp-learn/hello.cpp
V[23:42:20.036] <<< {"id":2,"jsonrpc":"2.0","method":"textDocument/inlayHint","params":{"range":{"end":{"character":1,"line":7},"start":{"character":0,"line":0}},"textDocument":{"uri":"file:///mnt/part7/code/cpp-learn/hello.cpp"}}}

I[23:42:20.036] <-- textDocument/inlayHint(2)
I[23:42:20.036] --> reply:textDocument/documentLink(1) 0 ms
V[23:42:20.036] >>> {"id":1,"jsonrpc":"2.0","result":[]}

V[23:42:20.036] ASTWorker running InlayHints on version 1 of /mnt/part7/code/cpp-learn/hello.cpp
I[23:42:20.036] --> reply:textDocument/inlayHint(2) 0 ms
V[23:42:20.036] >>> {"id":2,"jsonrpc":"2.0","result":[]}

I[23:42:20.036] --> textDocument/clangd.fileStatus
V[23:42:20.036] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"idle","uri":"file:///mnt/part7/code/cpp-learn/hello.cpp"}}

V[23:42:20.037] <<< {"id":3,"jsonrpc":"2.0","method":"textDocument/semanticTokens/full","params":{"textDocument":{"uri":"file:///mnt/part7/code/cpp-learn/hello.cpp"}}}

I[23:42:20.037] <-- textDocument/semanticTokens/full(3)
V[23:42:20.037] ASTWorker running SemanticHighlights on version 1 of /mnt/part7/code/cpp-learn/hello.cpp
I[23:42:20.037] --> reply:textDocument/semanticTokens/full(3) 0 ms
V[23:42:20.037] >>> {"id":3,"jsonrpc":"2.0","result":{"data":[1,16,3,15,131072,2,4,4,3,131075],"resultId":"1"}}

I[23:42:20.037] --> textDocument/clangd.fileStatus
V[23:42:20.037] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"idle","uri":"file:///mnt/part7/code/cpp-learn/hello.cpp"}}

V[23:42:20.056] <<< {"id":4,"jsonrpc":"2.0","method":"textDocument/codeAction","params":{"context":{"diagnostics":[],"triggerKind":2},"range":{"end":{"character":1,"line":7},"start":{"character":1,"line":7}},"textDocument":{"uri":"file:///mnt/part7/code/cpp-learn/hello.cpp"}}}

I[23:42:20.056] <-- textDocument/codeAction(4)
V[23:42:20.056] ASTWorker running EnumerateTweaks on version 1 of /mnt/part7/code/cpp-learn/hello.cpp
I[23:42:20.056] --> reply:textDocument/codeAction(4) 0 ms
V[23:42:20.056] >>> {"id":4,"jsonrpc":"2.0","result":[]}

I[23:42:20.057] --> textDocument/clangd.fileStatus
V[23:42:20.057] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"idle","uri":"file:///mnt/part7/code/cpp-learn/hello.cpp"}}

V[23:42:20.111] <<< {"jsonrpc":"2.0","method":"$/setTrace","params":{"value":"off"}}

I[23:42:20.111] <-- $/setTrace
I[23:42:20.112] unhandled notification $/setTrace
V[23:42:20.416] <<< {"id":5,"jsonrpc":"2.0","method":"textDocument/foldingRange","params":{"textDocument":{"uri":"file:///mnt/part7/code/cpp-learn/hello.cpp"}}}

I[23:42:20.416] <-- textDocument/foldingRange(5)
I[23:42:20.416] --> reply:textDocument/foldingRange(5) 0 ms
V[23:42:20.416] >>> {"id":5,"jsonrpc":"2.0","result":[{"endLine":6,"kind":"region","startCharacter":12,"startLine":3}]}

V[23:42:20.466] <<< {"id":6,"jsonrpc":"2.0","method":"textDocument/codeAction","params":{"context":{"diagnostics":[],"triggerKind":2},"range":{"end":{"character":1,"line":7},"start":{"character":1,"line":7}},"textDocument":{"uri":"file:///mnt/part7/code/cpp-learn/hello.cpp"}}}

I[23:42:20.467] <-- textDocument/codeAction(6)
V[23:42:20.467] ASTWorker running EnumerateTweaks on version 1 of /mnt/part7/code/cpp-learn/hello.cpp
I[23:42:20.467] --> reply:textDocument/codeAction(6) 0 ms
V[23:42:20.467] >>> {"id":6,"jsonrpc":"2.0","result":[]}

I[23:42:20.467] --> textDocument/clangd.fileStatus
V[23:42:20.467] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"idle","uri":"file:///mnt/part7/code/cpp-learn/hello.cpp"}}

V[23:42:20.468] <<< {"id":7,"jsonrpc":"2.0","method":"textDocument/documentSymbol","params":{"textDocument":{"uri":"file:///mnt/part7/code/cpp-learn/hello.cpp"}}}

I[23:42:20.468] <-- textDocument/documentSymbol(7)
V[23:42:20.468] ASTWorker running DocumentSymbols on version 1 of /mnt/part7/code/cpp-learn/hello.cpp
I[23:42:20.468] --> reply:textDocument/documentSymbol(7) 0 ms
V[23:42:20.468] >>> {"id":7,"jsonrpc":"2.0","result":[{"kind":13,"name":"using namespace std","range":{"end":{"character":19,"line":1},"start":{"character":0,"line":1}},"selectionRange":{"end":{"character":19,"line":1},"start":{"character":16,"line":1}}},{"detail":"int ()","kind":12,"name":"main","range":{"end":{"character":1,"line":7},"start":{"character":0,"line":3}},"selectionRange":{"end":{"character":8,"line":3},"start":{"character":4,"line":3}}}]}

I[23:42:20.468] --> textDocument/clangd.fileStatus
V[23:42:20.468] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"idle","uri":"file:///mnt/part7/code/cpp-learn/hello.cpp"}}

V[23:42:22.288] <<< {"id":8,"jsonrpc":"2.0","method":"textDocument/inlayHint","params":{"range":{"end":{"character":1,"line":7},"start":{"character":0,"line":0}},"textDocument":{"uri":"file:///mnt/part7/code/cpp-learn/hello.cpp"}}}

I[23:42:22.288] <-- textDocument/inlayHint(8)
V[23:42:22.288] ASTWorker running InlayHints on version 1 of /mnt/part7/code/cpp-learn/hello.cpp
I[23:42:22.288] --> reply:textDocument/inlayHint(8) 0 ms
V[23:42:22.288] >>> {"id":8,"jsonrpc":"2.0","result":[]}

I[23:42:22.288] --> textDocument/clangd.fileStatus
V[23:42:22.288] >>> {"jsonrpc":"2.0","method":"textDocument/clangd.fileStatus","params":{"state":"idle","uri":"file:///mnt/part7/code/cpp-learn/hello.cpp"}}

System information

clangd and other installed compilers:

$ clang --version
Ubuntu clang version 14.0.0-1ubuntu1.1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
$ clangd --version
Ubuntu clangd version 14.0.0-1ubuntu1.1
Features: linux+grpc
Platform: x86_64-pc-linux-gnu
$ gcc --version
gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ g++ --version
g++ (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ clang++ --version
Ubuntu clang version 14.0.0-1ubuntu1.1
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin

Here is the installed extension lists:

$ code --list-extensions

13xforever.language-x86-64-assembly
aaron-bond.better-comments
adpyke.codesnap
ajshort.include-autocomplete
aliasadidev.nugetpackagemanagergui
anteprimorac.html-end-tag-labels
batisteo.vscode-django
cheshirekow.cmake-format
cschlosser.doxdocgen
dan-c-underwood.arm
danielpinto8zz6.c-cpp-compile-run
dbaeumer.vscode-eslint
donjayamanne.githistory
donjayamanne.python-environment-manager
dustypomerleau.rust-syntax
eamodio.gitlens
ecmel.vscode-html-css
esbenp.prettier-vscode
firefox-devtools.vscode-firefox-debug
formulahendry.code-runner
foxundermoon.shell-format
GitHub.github-vscode-theme
golang.go
icsharpcode.ilspy-vscode
JScearcy.rust-doc-viewer
KevinRose.vsc-python-indent
llvm-vs-code-extensions.vscode-clangd
maziac.asm-code-lens
maziac.hex-hover-converter
mcu-debug.debug-tracker-vscode
mgmcdermott.vscode-language-babel
modular-mojotools.vscode-mojo
ms-dotnettools.csdevkit
ms-dotnettools.csharp
ms-dotnettools.vscode-dotnet-runtime
ms-dotnettools.vscodeintellicode-csharp
ms-python.isort
ms-python.python
ms-python.vscode-pylance
ms-vscode.cmake-tools
ms-vscode.cpptools-extension-pack
ms-vscode.cpptools-themes
ms-vscode.live-server
ms-vscode.makefile-tools
ms-vscode.remote-explorer
ms-vscode.remote-server
njpwerner.autodocstring
oderwat.indent-rainbow
PKief.material-icon-theme
redhat.fabric8-analytics
redhat.java
redhat.vscode-xml
rust-lang.rust-analyzer
serayuzgur.crates
twxs.cmake
vadimcn.vscode-lldb
VisualStudioExptTeam.intellicode-api-usage-examples
VisualStudioExptTeam.vscodeintellicode
vscjava.vscode-java-debug
vscjava.vscode-java-dependency
vscjava.vscode-java-pack
vscjava.vscode-java-test
vscjava.vscode-maven
vscjava.vscode-spring-initializr
wholroyd.jinja
xabikos.JavaScriptSnippets
xaver.clang-format
yzhang.markdown-all-in-one
Zignd.html-css-class-completion
zokugun.cron-tasks
zokugun.sync-settings

Operating system

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.3 LTS
Release:    22.04
Codename:   jammy

$ uname -all
Linux UXPC2204OCT 6.2.0-36-generic #37~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Oct  9 15:34:04 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
HighCommander4 commented 11 months ago

Is it possible to fix this without installing libstdc++-12-dev, So when a user install clangd extension this problem doesn't occur at the first place?

Yes, please see https://github.com/clangd/clangd/issues/1394#issuecomment-1328676884 with a description of the problem, and four available workarounds. Only one of the four involves installing libstdc++-12-dev. (The comment talks about g++-12, I guess libstdc++-12-dev is the more specific dependency that brings in which is relevant.)

niamotullah commented 11 months ago

Is it possible to fix this without installing libstdc++-12-dev, So when a user install clangd extension this problem doesn't occur at the first place?

Yes, please see clangd/clangd#1394 (comment) with a description of the problem, and four available workarounds. Only one of the four involves installing libstdc++-12-dev. (The comment talks about g++-12, I guess libstdc++-12-dev is the more specific dependency that brings in which is relevant.)

Sorry, i guess there is some misunderstanding, As i already told, i resolved my issue (by installing libstdc++-12-dev). So intention of this bug report wasn't about for finding different ways of fixing the problem, Rather the intention was to ask for a solution (if there's so) where the problem wouldn't occur at the first place.

HighCommander4 commented 11 months ago

the intention was to ask for a solution (if there's so) where the problem wouldn't occur at the first place

This is discussed in the last paragraph of the comment I linked to:

I think a proper fix would involve fixing the clang driver's heuristics for locating standard library paths, to handle this situation correctly. [...] the code in question is not in clangd, it's upstream in libclangDriver