After cloning the Linux kernel and opening up for example /drivers/md/dm-zero.c in VSCode (with the C CPP extension) gives me an error at the last 3 lines saying: function returning array is not allowed.
Of course I know that this should not be an error since I just cloned and didn't adjust anything. Is there a setting in the C CPP extension that should be set?
Thanks!
Edit: The title is misleading: I know this has nothing to do with the kernel itself, but I wanted to specify that VSCode complains about something that was already written in the Linux Kernel source code
Edit2: The specific error is in these 3 lines: function returning array is not allowed C/C++(91)
MODULE_AUTHOR("Jana Saout <[email protected]>");
MODULE_DESCRIPTION(DM_NAME " dummy target returning zeros");
MODULE_LICENSE("GPL");
MODULE_AUTHOR for example expands to
#define __MODULE_INFO(tag, name, info) \
static const char __UNIQUE_ID(name)[] \
__used __section(".modinfo") __aligned(1) \
= __MODULE_INFO_PREFIX __stringify(tag) "=" info
I use GCC in Ubuntu 20.04
This comment in the vscode github repo solved the issue for me. Basically need to add some explicit include paths and compiler args to the c_cpp_properties.json file.
"includePath": [
"/usr/src/linux-headers-5.4.0-39-generic/arch/x86/include",
"/usr/src/linux-headers-5.4.0-39-generic/arch/x86/include/generated",
"/usr/src/linux-headers-5.4.0-39-generic/include",
"/usr/src/linux-headers-5.4.0-39-generic/arch/x86/include/uapi",
"/usr/src/linux-headers-5.4.0-39-generic/arch/x86/include/generated/uapi",
"/usr/src/linux-headers-5.4.0-39-generic/include/uapi",
"/usr/src/linux-headers-5.4.0-39-generic/include/generated/uapi",
"/usr/src/linux-headers-5.4.0-39-generic/ubuntu/include",
"/usr/lib/gcc/x86_64-linux-gnu/9/include"
],
"compilerArgs": [
"-nostdinc",
"-include", "/usr/src/linux-headers-5.4.0-39-generic/include/linux/kconfig.h",
"-include", "/usr/src/linux-headers-5.4.0-39-generic/include/linux/compiler_types.h"
]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With