我正在 IAR 平台上编写代码,并希望执行以下操作。我有一个 typedef
如下
struct timer {
uint32_t start;
uint32_t interval;
};
typedef (void) (*etimer_cb) (int,void*);
struct etimer {
struct timer timer;
struct etimer* next;
etimer_cb p;
};
在这些之后我声明了以下变量:
struct etimer periodic;
但出现错误:
"periodic" is declared with a never completed type.
我该如何解决?
最佳答案
删除 ()
来自 void
.
uint32_t
不是预定义类型。你需要#include <stdint.h>
.
#include <stdint.h>
struct timer{
uint32_t start;
uint32_t interval;
};
typedef void (*etimer_cb)(int, void *);
struct etimer{
struct timer timer;
struct etimer* next;
etimer_cb p;
};
但我更愿意不隐藏函数的指针
#include <stdint.h>
struct timer{
uint32_t start;
uint32_t interval;
};
typedef void etimer_cb(int, void *);
struct etimer{
struct timer timer;
struct etimer* next;
etimer_cb *p;
};
关于IAR 上的 C 编程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4427886/