当我查看一些代码时,我发现了这个声明。
typedef int (*tMeshTable)(tOutPar *);
它的目的是什么?
答案 0 :(得分:6)
tMeshtable typedef将成为获取tOutPar指针并返回int的函数的指针。
每次都说tMeshTable比整个事情更容易。
所以当你想把它传递给一个函数时,例如:
void functionThatCallsFunction(tMeshTable myFunction) {
tOutPar * outPar;
/* This next line calls the function that was passed into this function as a parameter */
int result = (*myFunction)(outPar);
}
它看起来比原始函数指针语法更清晰。
这个页面讨论了所有关于函数指针的内容。你应该看看:http://www.newty.de/fpt/fpt.html