编译程序时,Keil报错: #81: more than one storage class may not be specified

*** Using Compiler 'V5.06 update 2 (build 183)', folder: 'C:\Program Files (x86)\Keil_v5\ARM\ARMCC\Bin'
Rebuild target 'Target 1'
compiling genLinConfig.c...
compiling lin_main.c...
compiling lin_slave_task.c...
compiling lin_hal.c...
compiling linmain.c...
compiling lin_diagnostic_Service.c...
compiling lin_driver_api.c...
compiling motor_control.c...
.\Includes\Boot.h(74): error:  #81: more than one storage class may not be specified
      extern static DATA_SAVE_FLAG_STRUCT dataSaveFlag;
Sources\motor_control.c: 0 warnings, 1 error
compiling Roof_functions.c...
.\Includes\Boot.h(74): error:  #81: more than one storage class may not be specified
      extern static DATA_SAVE_FLAG_STRUCT dataSaveFlag;
Sources\Roof_functions.c: 0 warnings, 1 error
compiling protect_function.c...
.\Includes\Boot.h(74): error:  #81: more than one storage class may not be specified
      extern static DATA_SAVE_FLAG_STRUCT dataSaveFlag;
Sources\protect_function.c: 0 warnings, 1 error
compiling main.c...
.\Includes\Boot.h(74): error:  #81: more than one storage class may not be specified
      extern static DATA_SAVE_FLAG_STRUCT dataSaveFlag;
main.c: 0 warnings, 1 error
compiling LIN_command.c...
.\Includes\Boot.h(74): error:  #81: more than one storage class may not be specified
      extern static DATA_SAVE_FLAG_STRUCT dataSaveFlag;
Sources\LIN_command.c: 0 warnings, 1 error
compiling RelayProcess.c...
compiling anti_pinch_function.c...
.\Includes\Boot.h(74): error:  #81: more than one storage class may not be specified
      extern static DATA_SAVE_FLAG_STRUCT dataSaveFlag;
Sources\anti_pinch_function.c: 0 warnings, 1 error
compiling HwInput.c...
compiling key_input.c...
compiling Boot.c...
.\Includes\Boot.h(74): error:  #81: more than one storage class may not be specified
      extern static DATA_SAVE_FLAG_STRUCT dataSaveFlag;
Sources\Boot.c: 0 warnings, 1 error
compiling SoftTimerCounter.c...
compiling StateMachine.c...
.\Includes\Boot.h(74): error:  #81: more than one storage class may not be specified
      extern static DATA_SAVE_FLAG_STRUCT dataSaveFlag;
Sources\StateMachine.c: 0 warnings, 1 error
compiling EE_emulation.c...
compiling interrupt_serve.c...
.\Includes\Boot.h(74): error:  #81: more than one storage class may not be specified
      extern static DATA_SAVE_FLAG_STRUCT dataSaveFlag;
Sources\interrupt_serve.c: 0 warnings, 1 error
compiling Motor_id.c...
compiling UDS_Memory_Service.c...
.\Includes\Boot.h(74): error:  #81: more than one storage class may not be specified
      extern static DATA_SAVE_FLAG_STRUCT dataSaveFlag;
Sources\UDS_Memory_Service.c: 0 warnings, 1 error
compiling adc2.c...
compiling adc1.c...
compiling bootrom.c...
compiling gpt12e.c...
compiling ccu6.c...
compiling hs.c...
compiling int.c...
compiling isr.c...
compiling lin.c...
compiling ls.c...
compiling mon.c...
compiling pmu.c...
compiling port.c...
compiling scu.c...
compiling ssc.c...
assembling startup_tle984x.s...
compiling timer2x.c...
compiling system_tle984x.c...
compiling tle_device.c...
compiling wdt1.c...
compiling uart.c...
".\Objects\Test 9843_2QX.axf" - 10 Error(s), 0 Warning(s).
Target not created.
Build Time Elapsed:  00:00:12

查看下原因是定义变量时有误:

extern static DATA_SAVE_FLAG_STRUCT dataSaveFlag;

被static修饰的全局变量,作用域会修改,生命周期不会改,只能在当前文件下使用。

extern作用是用来声明外部全局变量。如果变量加了extern修饰,先会去当前文件下查找有没有对应全局变量,如果没有,才会去其他文件查找。

这两个修饰是冲突的,需要将static修饰去掉,然后进行编译,就不会再次报错。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

WangLanguager

您的鼓励是对我最大的支持

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值