Issue
I'm attempting to develop a kernel driver using visual studio code on Linux. For syntax highlighting I'm used to using clangd with cmake.
I tried to set up a cmake file for kernel dev, but I'm not able to get it to work. As for now I'm just using a simple makefile.
obj-m += src/*.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
This solution is fine, but this means that I have no intellisense. How can I set up intellisense for Linux kernel dev?
Solution
I was able to find a solution. After looking at the clangd installation documentation, it was described;
For a make-based build, you can run make clean; bear -- make
to generate the file (and run a clean build!).
After making my makefile like below and running the command above. Visual Studio Code + clangd was able to resolve the intellisense by itself.
obj-m += Driver.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
Answered By - MegaMagnum Answer Checked By - Mildred Charles (WPSolving Admin)