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;
}

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.