Keil ARM C compiler: troubles with inline functions

4.4k views Asked by At

I'm porting the real-time kernel TNeoKernel to the Cortex-M architecture, so I've installed Keil and am trying to build the kernel. However, I'm facing unexpected issues: the compiler seems not being able to handle inline functions. Here's simple code:

static inline int test(void)
{
   return 0;
}

Compiler's output is as follows:

src\appl\main.c(17): warning:  #260-D: explicit type is missing ("int" assumed)
  static inline int test(void)
src\appl\main.c(17): error:  #65: expected a ";"
  static inline int test(void)

If I remove the inline keyword, it compiles and works.

In the documentation of ARM Compiler I can't find anything about inline functions. So, just to make sure: is the inline keyword really not supported by the ARM Compiler? It is too unbelievable so I decided to ask.

I have many static inline functions in the kernel's platform-independent code, so, what is the best way to make it support ARM compiler? Off the top of my head, I have just two ideas:

  • create architecture-dependent macro like TN_INLINE, and for ARM compiler it should expand to nothing;
  • convert really small 1-line functions to macros.
1

There are 1 answers

3
ouah On BEST ANSWER

inline keyword has been introduced in c99 but by default Keil ARM C compiler compiles in c89/c90 mode.

Keil documentation explicitly says that inline is not available in c90:

The inline keyword is not available in C90.

Keil ARM C compiler also supports c99. Use --c99 compiler option to switch to c99 mode or try to use __inline extension keyword when in c90 mode: