I have some codes about Linux kernel driver. I use bear make to generate compile_commands.json.
this is some of my compile_commands.json:
"directory": "/usr/src/linux-headers-5.4.0-90-generic",
"file": "../../../home/ubuntu/programs/linuxKLearn/2/2.1/PrintingDriver/DriverFileOperations.c"
this is my Makefiles:
ifneq ($(KERNELRELEASE),)
obj-m := PrintModule.o
PrintModule-objs := DriverMain.o DriverFileOperations.o
EXTRA_CFLAGS := -DTEST_DEBUG -ggdb -O0
else
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
default:
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
rm *.order *.symvers *.mod.c *.o .*.o.cmd .*.cmd .tmp_versions -rf
endif
But when I use Vscode and clangd to read them, clangd shows that there is some problems when including <linux/mm.h>, the problems are as below:
Unknown argument: '-mno-fp-ret-in-387'
Unknown argument: '-mpreferred-stack-boundary=3'
Unknown argument: '-mskip-rax-setup'
Unknown argument: '-mindirect-branch=thunk-extern'
Unknown argument: '-mindirect-branch-register'
......
And clangd cannot find ssize_t. Unknown type name 'ssize_t'clang(unknown_typename) .the inode also has warning Declaration of 'struct inode' will not be visible outside of this functionclang(-Wvisibility),
How to fix include <linux/mm.h> and find ssize_t?
All help is welcome, thanks :)