# Implicit declaration is invalid warning for __set_BASEPRI() function in Keil

I'm trying to use a __set_BASEPRI() function in Keil to set up interrupts in STM32F407 but it doesn't work when I compile the code and the IDE shows warning "implicit declaration of function '__set_BASEPRI' is invalid in C99". Functions __enable_irq() and __disable_irq() work fine. How do I make it work?

Also weird, when I click on "Go to definition" on all these functions, the IDE cannot find the source file for them even though cmsis_armcc.h is included in the project.

• Do a text file search for "__set_BASEPRI" in all the .h file you have at disposal. Probably you will gather some info. – linuxfan says Reinstate Monica Mar 10 at 7:16
• @linuxfansaysReinstateMonica its included in cmsis_armcc.h, cmsis_armclang.h and cmsis_gcc.h. The former is included in my project. – Archimedes Mar 10 at 8:03

## 3 Answers

__get_BASEPRI() is defined in cmsis_armcc.h, but only if __TARGET_ARCH_7E_M (ARMv7-M, Cortex-M3) or __TARGET_ARCH_7E_M (ARMv7E-M, Cortex-M4, M7) is defined. The BASEPRI special register is not supported in ARMv6-M, Cortex-M0, M0+, and M1. Make sure you have the correct device selected in the Options for Target dialog.

That usually happens when the prototype is not included. Have you included the relevant .h file?

• Keil includes cmsis_armcc.h automatically. Including it manually doesn't fix the problem. I also tried a fresh Keil install on another PC and everything works fine, so this is probably an IDE problem, not my code. Reinstalling Keil on my PC didn't help. – Archimedes Mar 10 at 8:04
• @Archimedes If a re-install did not fix it on your machine but did on another, that suggests something is "left behind" in the registry – Dirk Bruere Mar 10 at 15:35

The problem lied in a compiler I was using. By default Keil uses ARMCC (default compiler 5). When I switched to ARMCLANG (default compiler 6), the problem resolved.