static関数を別ファイルの関数からコールする???
まず最初に言っておくと,わたしの勘違いです.
http://www23.atwiki.jp/selflearn/pages/20.html
こちらの方の「static関数を別ファイルの関数からコールする」という記事で,
static関数が外部ソースからコールできると書いてあったので,例えば
/* main.c */ #include <stdio.h> #include "sub.h" int call_sub(int (*func)()) { return (*func)(); } int main() { call_sub(sub); return 0; }
/* sub.c */ #include <stdio.h> #include "sub.h" static int sub() { return printf("call sub()\n"); }
/* sub.h */ static int sub();
で,こんなことできるのかとinetutils-1.5/ping/見てみたら,違ってて
/* main.c */ #include <stdio.h> #include "sub.h" static int sub(void); // static int sub(void); static int sub() { return printf("call sub()\n"); } int main() { call_sub(sub); return 0; }
/* sub.c */ #include <stdio.h> #include "sub.h" int call_sub(int (*func)()) { return (*func)(); }
/* sub.h */ int call_sub(int (*func)());
だった.