gpt4 book ai didi

IAR 上的 C 编程

转载 作者:太空宇宙 更新时间:2023-11-03 23:35:38 24 4
gpt4 key购买 nike

我正在 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/

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