IAR 上的 C 编程

标签 c iar stm32

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

相关文章:

c - 如何在C中执行循环宏

c - #define 问题与#pragma

arm - 如何检查应用程序的 cortex m3 SRAM 使用情况

c - 使用 HAL 库的 STM32l100rc USB 驱动程序

c - 如何在C程序中显示当前时间,在CodeVisionAVR中编译

c - 为什么我的代码可以正常创建文本文件,但只读取文本的第一个字符串?

计算数组中元素的数量 - C

c - map 文件中 STM32 的 IAR 堆栈使用情况

c - 点亮 STM32F103C8T6 上的 LED

arm - 关于STM32 HAL质量和性能