0

I'm trying to setup Vim as a C++ IDE on Mac. I followed this tutorial. So I'm using Coc and coc-clangd extension. Everything works perfect, except 2 things :

  • when I try to use c++ standard libs (stdio.h works for exemple but not iostream). It says it doesn't found the header file.
  • when I try to include custom header files stored in the "include" folder of my project. It says the same.

What I have tried : (.clangd file)

CompileFlags:
  Add: [-I/absolute-path-to-include-folder]
  Compiler: clang++

This solved the second problem, even if I would prefer relative path (relative path didn't seem to work). But changing compiler from clang to clang++ didn't solve the first one. I would like to try with compile_flags.txt or compile_command.json but I don't find enough documentation. Besides I build my project with Makefile and not CMake.

Any idea?

genpfault
  • 51,148
  • 11
  • 85
  • 139
sta
  • 23
  • 3
  • Use the blog's comment section. – romainl Aug 14 '23 at 18:13
  • Note that `stdio.h` is part of the C standard library and **not** of the C++ standard library. The corresponding file of C++ standard library would be `cstdio`. It's not completely clear from your question if you noted so I thought I'd point it out. – Friedrich Aug 15 '23 at 06:10
  • For standard library headers, I recommend using [--query-driver](https://clangd.llvm.org/guides/system-headers#query-driver). For generating compile_commands.json for a project using `make`, have a look at [bear](https://github.com/rizsotto/Bear) (see "Other build systems, using Bear" under https://clangd.llvm.org/installation#compile_commandsjson). – HighCommander4 Aug 18 '23 at 00:22

0 Answers0