假设我只想通过传递一个指向该函数的函数指针来从我的一个文件中公开一个函数。将该函数声明为 是否安全static
?是否允许编译器执行任何会使我的函数指针无效的柔道,或者在该文件的上下文之外使其无意义,因为该函数被声明为特定于该文件?
不是我的代码,而是我的意思的一个(愚蠢的)例子:
void static cool_function(void);
void extern (*cool_function_ptr)(void); // Actually, I’m not sure of where the `extern` goes in a function-
// pointer declaration. Damn you, confusing function-pointer syntax!
鉴于该代码(或其语法正确cool_function_ptr
的近似值),从另一个文件访问是否非法?