NXC  Version 1.2.1 r5
 All Data Structures Files Functions Variables Groups Pages
The inline keyword

You can optionally mark NXC functions as inline functions.

This means that each call to the function will create another copy of the function's code. Unless used judiciously, inline functions can lead to excessive code size.

If a function is not marked as inline then an actual NXT subroutine is created and the call to the function in NXC code will result in a subroutine call to the NXT subroutine. The total number of non-inline functions (aka subroutines) and tasks must not exceed 256.

The code example below shows how you can use the inline keyword to make a function emit its code at the point where it is called rather than requiring a subroutine call.

inline void foo(unsigned int frequency)
{
PlayTone(frequency, SEC_1);
}
task main()
{
foo(TONE_A4);
foo(TONE_B4);
foo(TONE_C5);
foo(TONE_D5);
}

In this case task main will contain 4 PlayTone calls and 4 Wait calls rather than 4 calls to the foo subroutine since it was expanded inline.