问题描述
C文件中定义的静态函数是否可以从另一个C文件外部引用(调用)
?如果是,在哪种条件下?
Can a static function defined in a C file be ever referred (called)
externally from another C file?If so in which conditions?
推荐答案
是的,如果你声明一个变量是这个函数的指针,并且
使它指向该函数(显然这必须在
文件中完成,其中`static`函数是)。如果该指针不是静态的,那么可以从其他地方使用它来调用该函数。
如果你想到函数/ names /,它会有所帮助,他们无法进入。
-
BR,Vladimir
INTOXICATED:
当你觉得复杂而不能发音时。
Yes, if you declare a variable to be a pointer to such a function, and
make it point to that function (obviously this has to be done in the
file where `static` function is). If that pointer is not static, it
can be used from elsewhere to call that function.
It may help if you think of function /names/, they''re not accessible.
--
BR, Vladimir
INTOXICATED:
When you feel sophisticated without being able to pronounce it.
你在说什么?你在跟谁说话?阅读:
< http://cfaj.freeshell.org/google/>
< http://clc-wiki.net/ wiki / Introduction_to_comp.lang.c>
另外,你的回答是错误的。将文件包含到另一个文件中会使其成为该文件的一部分,因此与原始问题无关。请参阅
我的其他帖子以获得正确的答案。
-
BR,Vladimir
我不知道第三次世界大战会用什么武器进行战斗,但是世界
第四次世界大战将用棍棒和石头进行战斗。
- - 阿尔伯特爱因斯坦
What are you talking about? Who are you talking to? Read:
<http://cfaj.freeshell.org/google/>
<http://clc-wiki.net/wiki/Introduction_to_comp.lang.c>
Also, your answer is wrong. Including a file into another makes it a
part of that file, and thus irrelevant to the original question. See
my other post for the correct answer.
--
BR, Vladimir
"I know not with what weapons World War III will be fought, but World
War IV will be fought with sticks and stones."
-- Albert Einstein
这篇关于可以在外部引用(调用)C文件中定义的静态函数吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!