Hi Can anybody tell me

What is the usage of Static functions and where we can use

what is the advantage of Static functions over Normal functions

Advance Thanks for helping

9 Years
Discussion Span
Last Post by Ragupathiyuva

>What is the usage of Static functions and where we can use
static functions have a visibility restricted to the translation unit in which they're declared. You can use them anywhere a regular function can be used, but you should use them everywhere you can because they follow the rule of minimal scope.


If you have a small program with just one *.c file, then static functions aren't all that useful. The advantage of statics is with larger programs whose projects consist of several *.c files. In this case, as Narue already said, make all the functions static that do not need global scope to other *.c files. And the same with global data objects, make them static too if they don't need to be referenced in more than one *.c file.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.