1. The list of problems when __WEAK is not recognized by Keil compilation is as follows.
A screenshot of the problem that sometimes occurs when __WEAK is not recognized when compiling with Keil is as follows.
The error message prompted is as follows:
..\..\..\..\mcu\common\interrupts_hc32l13x.c(72): error: #77-D: this declaration has no storage class or type specifier
__WEAK void Uart1_IRQHandler(void);
..\..\..\..\mcu\common\interrupts_hc32l13x.c(72): error: #65: expected a ";"
__WEAK void Uart1_IRQHandler(void);
..\..\..\..\mcu\common\interrupts_hc32l13x.c(73): error: #77-D: this declaration has no storage class or type specifier
__WEAK void LpUart0_IRQHandler(void);
..\..\..\..\mcu\common\interrupts_hc32l13x.c(73): error: #65: expected a ";"
__WEAK void LpUart0_IRQHandler(void);
..\..\..\..\mcu\common\interrupts_hc32l13x.c(74): error: #77-D: this declaration has no storage class or type specifier
__WEAK void LpUart1_IRQHandler(void);
..\..\..\..\mcu\common\interrupts_hc32l13x.c(74): error: #65: expected a ";"
__WEAK void LpUart1_IRQHandler(void);
..\..\..\..\mcu\common\interrupts_hc32l13x.c(75): error: #77-D: this declaration has no storage class or type specifier
__WEAK void Spi0_IRQHandler(void);
..\..\..\..\mcu\common\interrupts_hc32l13x.c(75): error: #65: expected a ";"
Solution:
Because it needs to be defined as __weak in Keil to be recognized (non-capitalized _WEAK), add the following lines of definition to the header file base_types.h file, and compile it OK!
#if defined (__ICCARM__)
#define __WEAK __WEAK __ATTRIBUTES
#elif defined (__CC_ARM)
#define __WEAK __weak
#else
#error "unsupported compiler!!"
#endif
2. Cause analysis
ARM series compilation tool chain: __CC_ARM__, __ICCARM__, __GNUC__, __TASKING__
In order to solve the problem reported above, __ICCARM__ and __CC_ARM are defined, and a description is made here.
__CC_ARM corresponds to the platform: ARM RealView.
RealView is a set of development tools including compilation, debugging and simulation, which should be used in combination with development environments such as uvision, eclipse or CodeWarrior to form an integrated development environment.
__ICCARM__ corresponds to the platform: IAR EWARM.
Embedded Workbench for ARM is an integrated development environment developed by IARSystems for ARM microprocessors (hereinafter referred to as IAR EWARM). Compared to other ARM development environments, IAR EWARM is easy to start, easy to use, and compact in code.
The corresponding platform of __GNUC__ is: GNU Compiler Collection:
GCC was originally intended to be a compiler written specifically for the GNU operating system, which is thoroughly free software.
Read More:
- How to Solve Keil Error: error: #29: expected an expression
- [Solved] KEIL Error: keil Error: failed to execute ‘C:\Keil\ARM\ARMCC‘
- [Solved] Cannot synthesize weak property in file using manual reference counting
- How to Solve Error: “initializer element is not constant”
- How to Solve Hdsc32 MDK compile error: #29 & #223-D
- How to Solve Kotlin unresolved reference error
- [Solved] Keil error: #101: “name“ has already been declared in the current scope
- How to Solve Error: Type mismatch: cannot convert from Object to Car
- Keil5 error: #29: expected an expression [Solved]
- How to Solve Archetype generate Error
- Android 10: How to Solve Systemui Error
- How to Solve OpenCV CVUI Error: LINK2019
- How to Solve Cordova integrates Gaode Map key error
- How to Solve null/hadoopbinary/wintils.exe Error
- How to Solve TypeError: type numpy.ndarray doesn’t define __round__ method
- How to Solve “/usr/bin/ld: skipping incompatible”
- How to Solve using stm32f4 to drive PS2 error
- Error: env [NODE_ENV] is not set (How to Solve)
- How to Solve QT error: LNK1158: Cannot Run “rc.exe”
- keil: ERROR L107:ADDRESS SPACE OVERFlOW [How to Solve]