接到项目需要将驱动编译成ko文件, 将驱动代码放到kernel路径下,执行make modules 后编译报错
error: variable '__this_module' has initializer but incomplete type
error: unknown field 'name' specified in initializer
error: excess elements in struct initializer [-Werror]
error: (near initialization for '__this_module') [-Werror]
error: unknown field 'init' specified in initializer
error: excess elements in struct initializer [-Werror]
error: (near initialization for '__this_module') [-Werror]
error: unknown field 'arch' specified in initializer
error: 'MODULE_ARCH_INIT' undeclared here (not in a function)
error: excess elements in struct initializer [-Werror]
error: (near initialization for '__this_module') [-Werror]
导致此问题的原因是因为Android 源码默认关闭了可单独编译ko的功能,执行 make menuconfig 修改配置,在kernel下重新编译