Keil Logo


Information in this article applies to:

  • GNU C Compiler for ARM Version 3.22


I have a complex interrupt function that uses local variables. It seems that the GNU compiler does not generate correct code for it. Is there a known problem?

My code looks like:

void intr_func (void) __attribute__ ((interrupt));    // Generate Interrupt

void intr_func (void)  {
  int a, b, c, d;

  :   /* function code */


Yes, there is a problem in the GNU V3.22 compiler. For the moment, we recommend using the following work-around:

void intr_wrapper (void) __attribute__ ((interrupt));    // Generate Interrupt

void intr_wrapper (void)  {
  intr_func ();

Use the wrapper function around the interrupt and the correct code is generated.

Note: There have been many different variants of the GCC compiler for ARM devices. Modern versions of Keil still support the GCC compiler, but now uses the GNU Arm Embedded Toolchain, which fixed this issue. To use this toolchain with Keil, see GCC: Using a GNU GCC Compiler Toolchain in the IDE.

See Also

Last Reviewed: Thursday, August 9, 2018

Did this article provide the answer you needed?
Not Sure
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.