How to call the static function from another c file?

前端 未结 6 1706
谎友^
谎友^ 2021-02-07 22:48

I want to call a static function from another C file. But it always show \"function\" used but never defined.

In ble.c

6条回答
  •  Happy的楠姐
    2021-02-07 23:18

    The keyword static is often used to encapsulate the function in the source file where it is defined. So it is not meant to call a static function from outside, an other c-file. An extern article[^] is explaining that topic pretty good I think.

    Quote:

    Static functions are much like private methods in Java or C++. A private method is a method which is only used by a class and can't be used outside of it. In C, we can declare a static function. A static function is a function which can only be used within the source file it is declared in.

    So as a conclusion if you need to call the function from outside you do not define the function as static.

提交回复
热议问题