0

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.
5gon12eder
  • 24,280
  • 5
  • 45
  • 92
Dmitry Frank
  • 10,417
  • 10
  • 64
  • 114

1 Answers1

5

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:

ouah
  • 142,963
  • 15
  • 272
  • 331
  • Thanks. I've been read PDF documentation from infocenter.arm.com: http://infocenter.arm.com/help/topic/com.arm.doc.dui0471j/DUI0471J_software_development_guide.pdf , there's nothing about `--c99`. – Dmitry Frank Nov 13 '14 at 01:44
  • 2
    @DmitryFrank You were not looking at the right PDF documentation: the one you linked is "ARM Compiler Software Development Guide ". The PDF compiler documentation is "armcc User Guide" http://infocenter.arm.com/help/topic/com.arm.doc.dui0472j/DUI0472J_armcc_user_guide.pdf – ouah Nov 13 '14 at 01:58
  • Thanks again. I'm still quite new to the ARM ecosystem, yet learning. – Dmitry Frank Nov 13 '14 at 02:00