clangd icon indicating copy to clipboard operation
clangd copied to clipboard

The function is defined in the .c file. Using vscode-clangd to go to the definition does not take effect.

Open zx616456607 opened this issue 1 year ago • 4 comments

Please describe the problem. For hints on what information is helpful, see: https://clangd.llvm.org/troubleshooting.html

Installing clangd in Theia and VSCode is the same problem

If you can, provide a minimal chunk of code that shows the problem (either inline, or attach it if larger).

Logs

Please attach the clangd stderr log if you can. (Usually available from the editor) If possible, run with --log=verbose - note that the logs will include the contents of open files! If this is a crash, try to put llvm-symbolizer on your PATH per the troubleshooting instructions.

System information

Output of clangd --version: 16.0.0

Editor/LSP plugin: vscode-clangd 0.1.24

Operating system: Windows 10

zx616456607 avatar Feb 23 '24 02:02 zx616456607

Please take another look at the bug report template, and actually provide the requested information, instead of just copying the questions. In particular:

If you can, provide a minimal chunk of code that shows the problem (either inline, or attach it if larger).

and

Please attach the clangd stderr log if you can. (Usually available from the editor)

HighCommander4 avatar Feb 23 '24 05:02 HighCommander4

New header file testh.h Contents of the file: void swap(int a, int b);

New source file testc.c Contents of the file: ` #include "testh.h"

Void swap (int a, int b) { Int temp = a A = b B = temp } `

In the testh.h file, use the right mouse button to find the swap function definition, what appears is the list of function references, is the function normal?

image

image

image

zx616456607 avatar Feb 23 '24 06:02 zx616456607

Your project doesn't have a compile_commands.json file.

Please have a look at https://clangd.llvm.org/installation#project-setup.

Note that finding a definition in a different translation unit requires background indexing to work, so compile_flags.txt is not sufficient, compile_commands.json needs to be used.

HighCommander4 avatar Feb 23 '24 06:02 HighCommander4

Your project doesn't have a compile_commands.json file.

Please have a look at https://clangd.llvm.org/installation#project-setup.

Note that finding a definition in a different translation unit requires background indexing to work, so compile_flags.txt is not sufficient, compile_commands.json needs to be used.

I was also troubled by this problem untill I saw your answer. Thank you for your this ! It is easy for newbies like us to be blocked by some small problems

theSprog avatar Apr 20 '24 08:04 theSprog