【发布时间】:2012-04-03 18:50:57
【问题描述】:
#include <stdio.h>
struct context;
struct funcptrs{
void (*func0)(context *ctx);
void (*func1)(void);
};
struct context{
funcptrs fps;
};
void func1 (void) { printf( "1\n" ); }
void func0 (context *ctx) { printf( "0\n" ); }
void getContext(context *con){
con=?; // please fill this with a dummy example so that I can get this working. Thanks.
}
int main(int argc, char *argv[]){
funcptrs funcs = { func0, func1 };
context *c;
getContext(c);
c->fps.func0(c);
getchar();
return 0;
}
我在这里遗漏了一些东西。请帮我解决这个问题。谢谢。
【问题讨论】:
-
C 不允许你只说
context *whatever;,是吗?我想这肯定让你说struct context *whatever;...
标签: c struct declaration forward-declaration