'Register external C library to avoid incorrect diagnostics / treesitter highlighting in neovim

I want to write a C file + get correct diagnostics and tree-sitter syntax highlighting in neovim. Everything works fine, unless I include an external library (in this case Rinternals.h from the R language) because the symbols used there are somehow not registered.

I know that I could include this in my system library path but I have read that this is bad practice, so I wonder: How to I "register" these additional headers?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source