pragma(inline)

You will learn about pragma(inline) in this lesson.

We'll cover the following

Use of pragma(inline)

pragma(inline) specifies whether a function should be inlined or not.

Every function call has some performance cost. Function calls involve passing arguments to the function, returning its return value to the caller, and handling some bookkeeping information to remember where the function was called from so that the execution can continue after the function returns.

This cost is usually insignificant compared to the cost of actual work that the caller and the callee perform. However, in some cases, just the act of calling a certain function can have a measurable effect on the program’s performance. This can happen especially when the function body is relatively fast and when it is called from a short loop that repeats many times.

The following program calls a small function from a loop and increments a counter when the returned value satisfies a condition:

Get hands-on with 1200+ tech skills courses.