C - 参数名称省略?找不到错误

标签 c hardware intel

所以我正在为大学编程 Intel 8253 PIT,但我认为上下文与这个问题无关。因此,我正在尝试编译我的文件,但不断收到“参数名称省略”错误,我真的不知道为什么。

这一切都是在连接到大学服务器的 Minix VM 中编译的。我只需 cd 到该文件夹​​并输入“Make”,命令就会自动执行。实在不知道详情。更多信息如下:

功能:

int timer_test_read_config(uint8_t timer, enum timer_status_field field) {
  uint8_t temp;
  timer_display_conf(timer,temp,field);
  return 1;
}

枚举声明:

enum timer_status_field {
    all,        /*!< configuration/status */
    initial,    /*!< timer initialization mode */
    mode,       /*!< timer counting mode */
    base        /*!< timer counting base */
};

错误消息:

lab.c:33:5: error: parameter name omitted
int timer_test_read_config(uint8_t timer, enum timer_status_field field) {

为什么我会收到错误消息?我真的不明白。我可能真的很蠢,但是是的,我需要一些帮助。谢谢!

最佳答案

下面的旧答案,因对问题的编辑而无效。

现在如果没有更详细的 MCVE,这是无法回答的,因为如果您添加 #include <stdint.h>,当前代码可以使用 gcc 编译得很好。 。 (https://godbolt.org/z/VKZmU4)。

<小时/>

您忘记了结尾的 ;在你的 enum 的末尾声明。

enum timer_status_field {
    all,        /*!< configuration/status */
    initial,    /*!< timer initialization mode */
    mode,       /*!< timer counting mode */
    base        /*!< timer counting base */
};  /// Note added ; on this line

这编译得很好。单独编译文件中的原始枚举声明以获得更清晰的错误消息:

foo.c:6:1: error: expected identifier or ‘(’ at end of input
 }
 ^

} 之后的内容,您的编译器试图将其解释为该类型的变量,因为 enum { foo, bar } varname;是一个有效的声明。

<小时/>

通过此更改,您的整个代码可以很好地编译(带有 #include <stdint.h> ),当然只是警告未声明的函数。

关于C - 参数名称省略?找不到错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52671146/

相关文章:

math - 算术溢出时硬件中断?

c++ - i5-2500k 上的 cpuid 指令 : MMX, SSE,SSE2 位未设置

c - 关于 "static"的用法,非常基本

摄氏度到华氏度与 C 中的指针

c - C 的定时器非常精确?如此精确地测量单个函数调用

iphone - 用于检查 iPhone 与 USB 的连接的应用程序

C编程,错误: called object is not a function or function pointer

java - 在地理位置相同的虚拟机上运行 map reduce - 对于 hadoop 集群来说,这种设置有多糟糕?

math - 英特尔MKL与AMD Math Core库

performance - 为什么在 L1 缓存中使用 MFENCE 和存储指令 block 预取?