编译程序时,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修饰去掉,然后进行编译,就不会再次报错。

你可能感兴趣的:(编译程序时,Keil报错: #81: more than one storage class may not be specified)