Static functions declared in “C” header files

后端 未结 3 1642
执笔经年
执笔经年 2021-02-01 03:21

For me it\'s a rule to define and declare static functions inside source files, I mean .c files.

However in very rare situations I saw people declaring it in the header

3条回答
  •  温柔的废话
    2021-02-01 03:49

    Why would you want a both global and static function? In c, functions are global by default. You only use static functions if you want to limit the access to a function to the file they are declared. So you actively restrict access by declaring it static...

    The only requirement for implementations in the header file, is for c++ template functions and template class member functions.

提交回复
热议问题