0

What is the use of making static function inline ? Rather than using the same function in two files ; is their any other use of static function?

inline static int func(int a)
{    
    static int b;     
    printf("Hello World !\n");    
    return b;
}
jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
Rohith Gowda
  • 137
  • 2
  • 2
  • 12

1 Answers1

1

inline is always just a hint to the compiler that you'd like the function inlined rather than called normally. It's not obliged to pay attention, though.

static makes your function available only to the current translation unit. That's useful for writing helper functions whose functionality you don't want exported, for example. Or, as you say, if you have to use the same function name in two translation units for some reason.

Carl Norum
  • 219,201
  • 40
  • 422
  • 469