The following code may require a certain C + + base.
Need some knowledge of function pointers
Depth profiling function pointer click here
Common.h
#pragma oncetypedef int (*pt) (void); void init_2 ();
2.cpp
#include
#include "Common.h" using namespace std;static pt Next_pt;extern pt Top_pt;int filter_2 () {cout<< ' filter_2 ' <
1.cpp
#include
#include "common.h" using namespace std;static pt next_pt;pt top_pt;static int fil Ter_1 () {cout<< "filter_1" <
compile command
g++ 1.cpp 2.cpp-g-o0
Execute
./a.out
Filter_2
filter_1
If you've programmed and executed successfully
, please continue looking down.
Top_pt is a global variable
Next_pt is a local global variable
If you want to know
The
Top_pt will change every time the code executes, pointing to the new list header, and a linked list is generated by the continuous execution of the init_* function. It looks like a single list with global variables.
Well, it's the trick, too!
Above introduces similar Nginx compile-time generated function chain list, including the contents of the content, I hope that the ph P Tutorials Interested friends are helpful.