The system is a fresh installation of Raspbian. I have updated and upgraded all packages on the system, and installed the raspberrypi-kernel-headers package. uname -r gives 4.14.79+. The directory /usr/src/linux-headers-4.14.79+ exists, and /lib/modules/4.14.79+/build correctly symlinks to the former.
However, I get very weird error messages when trying to compile a kernel module.
Here is a minimal example:
Code: Select all
// module.c
#include <linux/module.h>
MODULE_LICENSE("GPL v2");
Code: Select all
# Makefile
KVERSION := $(shell uname -r)
PWD := $(shell pwd)
obj-m := module.o
all:
+make -C /lib/modules/$(KVERSION)/build/ M=$(PWD) modules
clean:
+make -C /lib/modules/$(KVERSION)/build/ M=$(PWD) clean
Code: Select all
make -C /lib/modules/4.14.79+/build/ M=/home/pi modules
make[1]: Entering directory '/usr/src/linux-headers-4.14.79+'
CC [M] /home/pi/module.o
/home/pi/module.c:3:16: error: expected declaration specifiers or ‘...’ before string constant
MODULE_LICENSE("GPL v2");
^~~~~~~~
scripts/Makefile.build:334: recipe for target '/home/pi/module.o' failed
make[2]: *** [/home/pi/module.o] Error 1
Makefile:1527: recipe for target '_module_/home/pi' failed
make[1]: *** [_module_/home/pi] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-4.14.79+'
Makefile:7: recipe for target 'all' failed
make: *** [all] Error 2
So, my question, is this really a bug or am I just missing something?