需要有一些函数指针的知识
深度剖析函数指针点击这里
common.h
#pragma oncetypedef int (*pt)(void);void init_2();
2.cpp
#include #include common.husing namespace std;static pt next_pt;extern pt top_pt;int filter_2(){ cout 1.cpp#include #include common.husing namespace std;static pt next_pt;pt top_pt;static int filter_1(){ cout编译命令 g++ 1.cpp 2.cpp -g -o0
执行
./a.out
filter_2
filter_1
如果你已经编程并执行成功,请继续往下看.
top_pt 为全局变量
next_pt为局部全局变量
如果你想知道
top_pt 在每次代码执行时都会变化,不断地指向新的链表头部,通过init_*函数的不断执行,一条链表就产生了。看起来就像是用全局变量组成了一条单项链表。
好吧,又是奇淫技巧,如是而已!
以上就介绍了类似 nginx 编译时生成函数链表,包括了方面的内容,希望对php教程有兴趣的朋友有所帮助。
