gpt4 book ai didi

c - 如何使用typedef定义函数类型?

转载 作者:行者123 更新时间:2023-12-04 14:35:37 25 4
gpt4 key购买 nike

我想知道是否可以使用 typedef 定义函数类型,我试过这个语法:

typedef int (*) (void *, void *) order;

但它不起作用。
错误消息: expected identifier or '(' before ')' token

最佳答案

如果是变量声明,则别名应该放在变量名所在的位置。

这里:

typedef int (*order) (void *, void *);
// ^~~~~

或者,如果您想要函数类型而不是函数指针:
typedef int order(void *, void *);

关于c - 如何使用typedef定义函数类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59030293/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com