typedef struct foo{
void (*del)(void *toDel);
char* (*p)(void *tp)
} Foo;
Foo init(char* (*print)(void*),void (*delFunc)(void*));
试图找出如何分配或初始化提供给struct函数指针的参数。初始化结构中的函数指针
typedef struct foo{
void (*del)(void *toDel);
char* (*p)(void *tp)
} Foo;
Foo init(char* (*print)(void*),void (*delFunc)(void*));
试图找出如何分配或初始化提供给struct函数指针的参数。初始化结构中的函数指针
Foo init(char* (*print)(void *toBePrinted),void (*delFunc)(void *toBeDeleted))
{
return Foo{ .del = delFunc, .p = print};
}
这个是什么?龙形态:
Foo init(char* (*print)(void *toBePrinted),void (*delFunc)(void *toBeDeleted))
{
Foo tmp = {
.del = delFunc,
.p = print
};
return tmp;
}
How to initialize a struct in accordance with C programming language standards
你可以做到这一点的常用方法:
Return (Foo){.del=delFunc, .p=print};
的直线前进(最向后兼容的方法)来定义foo
为Foo
并初始化它:
Foo foo = { /* Mind the order of the following initialisers! */
delFunc,
print
};
did you mean .del = delFunc .p = print? – waffles
@waffles是的,确切地说,对不起 –
是C99还是C11标准符号? – iBug