vim - 如何使用 coc-clangd 在 vi​​m 中使用 lib gtk 进行 C 编程?

标签 vim clang clang++ coc.nvim clangd

我复制了"Hello world" code from the website of the GTK project并将其粘贴到 Vim 中,并使用正确配置的 C 语言开发环境 coc-clangd 。但是,在

中显示了几个错误

#include <gtk/gtk.h>

但是当我使用命令发送编译时:

gcc `pkg-config --cflags gtk+-3.0` -o hello-world-gtk hello-world-gtk.c `pkg-config --libs gtk+-3.0`

效果很好 我尝试添加

`pkg-config --cflags gtk+-3.0`

clangd.fallbackFlags

:CocConfig但没有成功。

最佳答案

https://clangd.llvm.org/troubleshooting.html

https://sarcasm.github.io/notes/dev/compilation-database.html

clang -MJ hello-world-gtk.o.json `pkg-config --cflags gtk+-3.0` -o hello-world-gtk hello-world-gtk.c `pkg-config --libs gtk+-3.0`

sed -e '1s/^/[\n/' -e '$s/,$/\n]/' *.o.json >compile_commands.json

关于vim - 如何使用 coc-clangd 在 vi​​m 中使用 lib gtk 进行 C 编程?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64300017/

相关文章:

bash - Vim 从 bash 脚本运行命令并退出而不会使 shell 处于错误状态

vim - 如何在 Vim 中获得细粒度的撤消

c++ - 如何让 Clang 忽略特定 block 中的特定警告?

c++ - clang 的自定义分配器上的额外移动结构

c++ - 未在 clang++ 中编译的具有指向方法的指针的嵌套模板类

c++ - 当我使用 CMake 和 ninja 构建时,clang++ 会忽略 -MD 标志

Vim:了解本地设置 - 何时使用 buffer local 与 setlocal?

vim - 如何打开 vim 并自动将日期写入文件?

c++ - 在 Windows 上用 clang 编译 c++11 程序时出错

objective-c - 如何在 Xcode 中更改 MyFramework_vers.c 的编译标志?