24. Inline Functions

Question.3

A developer defines an inline function in a .cpp file and uses it from another:

utils.cpp:

inline uint8_t clamp(uint8_t val, uint8_t max) {
   return (val > max) ? max : val;
}

main.cpp:

extern uint8_t clamp(uint8_t, uint8_t);
uint8_t result = clamp(200, 100);

What happens?

Need Help? Refer to the Quick Guide below

Select Answer