-3

What are inline operators in C language?

I found this concept here: "until the inline operator becomes part of standard C, macros are the only portable way of generating inline code".

Source

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
DanielC
  • 13
  • 1
  • 6

1 Answers1

1

When you mark a function as inline, compiler merges body of that function into caller, so there is no extra effort to call the function, also compiler can do more optimization in the body of the caller and function.

if you have this function:

inline int min(int a, int b) {
    return a <= b? a: b;
}

when you calll this function, compiler won't use call, it will merge this code into caller code

jmowla
  • 166
  • 1
  • 4
  • Not completely true: `inline`, but also `register` are just suggestions to the compiler. The compiler will still decide what's best. (Actually a good compiler will inline small functions even without marking them with `inline`.) – meaning-matters Jan 01 '18 at 18:49
  • 1
    true, smart comiplers do more optimizations and decide what to optimize. – jmowla Jan 01 '18 at 18:55