編譯程序時,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修飾,先會去當前文件下查找有沒有對應(yīng)全局變量,如果沒有,才會去其他文件查找。

這兩個修飾是沖突的,需要將static修飾去掉,然后進行編譯,就不會再次報錯。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容