How to Solve UW Microcontroller KEIL _WEAK Error

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: