logo elektroda
logo elektroda
X
logo elektroda

Understanding Static Keyword for C Functions: Usage in Static Void Function_Name (void)

Marek_Gorecki 12505 3
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 9580318
    Marek_Gorecki
    Level 16  
    Hello;
    I am learning the C language and I came to a program in which there is a function preceded by the word Static. Something like that:

    static Void function_name (void)

    and I just don't understand it completely. I understand the static variable inside the function, but I don't understand marking the function as static.
  • ADVERTISEMENT
  • Helpful post
    #2 9580400
    tmf
    VIP Meritorious for electroda.pl
    This means that such a function will only be known in the compilation unit (source file) in which it is defined. Due to the fact that its name will be local, it is possible to optimize it better.
  • ADVERTISEMENT
  • Helpful post
    #3 9580451
    markosik20
    Level 33  
    tmf wrote:
    This means that such a function will only be known in the compilation unit (source file) in which it is defined. Due to the fact that its name will be local, it is possible to optimize it better.


    And if you try to call it from another file, the linker will throw an error.
  • #4 9580628
    Marek_Gorecki
    Level 16  
    Many thanks to both colleagues.
ADVERTISEMENT