一、问题

使用percpu变量时编译报错:

### make  in drv
make -C /usr/src/linux-wm M=/Packet/ac/module/saas_ctl/drv modules
  CC [M]  /Packet/ac/module/saas_ctl/drv/saas_action.o
  CC [M]  /Packet/ac/module/saas_ctl/drv/saas_main.o
/Packet/ac/module/saas_ctl/drv/saas_main.c: In function 'match_saas_rules':
/Packet/ac/module/saas_ctl/drv/saas_main.c:395: error: 'per_cpu__g_ssl_cpu_data' undeclared (first use in this function)
/Packet/ac/module/saas_ctl/drv/saas_main.c:395: error: (Each undeclared identifier is reported only once
/Packet/ac/module/saas_ctl/drv/saas_main.c:395: error: for each function it appears in.)
cc1: warnings being treated as errors
/Packet/ac/module/saas_ctl/drv/saas_main.c:395: error: type defaults to 'int' in declaration of 'type name'
/Packet/ac/module/saas_ctl/drv/saas_main.c:395: error: invalid type argument of 'unary *' (have 'int')
make[3]: *** [/Packet/ac/module/saas_ctl/drv/saas_main.o] Error 1
make[2]: *** [_module_/Packet/ac/module/saas_ctl/drv] Error 2
make[1]: *** [all] Error 2
make: *** [drv] Error 2

原因:

percpu变量在其他模块定义的,当前模块使用前要声明:

DECLARE_PER_CPU(type, name);

最后修改:2019 年 04 月 28 日
喜欢就给我点赞吧