c++ - C中的编译时错误

标签 c++ c linux cygwin

我正在尝试编译 C 代码 (davinci_spi.c)。对应的头文件如下:

davinci_spi.h:

    #ifndef _DAVINCI_SPI_H_
    #define _DAVINCI_SPI_H_

    struct davinci_spi_regs {
    dv_reg  gcr0;       /* 0x00 */
    dv_reg  gcr1;       /* 0x04 */
    dv_reg  int0;       /* 0x08 */
    dv_reg  lvl;        /* 0x0c */
    dv_reg  flg;        /* 0x10 */
    dv_reg  pc0;        /* 0x14 */
    dv_reg  pc1;        /* 0x18 */
    dv_reg  pc2;        /* 0x1c */
    dv_reg  pc3;        /* 0x20 */
    dv_reg  pc4;        /* 0x24 */
    dv_reg  pc5;        /* 0x28 */
    dv_reg  rsvd[3];
    dv_reg  dat0;       /* 0x38 */
    dv_reg  dat1;       /* 0x3c */
    dv_reg  buf;        /* 0x40 */
    dv_reg  emu;        /* 0x44 */
    dv_reg  delay;      /* 0x48 */
    dv_reg  def;        /* 0x4c */
    dv_reg  fmt0;       /* 0x50 */
    dv_reg  fmt1;       /* 0x54 */
    dv_reg  fmt2;       /* 0x58 */
    dv_reg  fmt3;       /* 0x5c */
    dv_reg  intvec0;    /* 0x60 */
    dv_reg  intvec1;    /* 0x64 */
    };

` (我认为剩余的文件代码并不重要,所以不包括它们)

当我尝试编译 davinci_spi.c 时出现此错误:


In file included from D:/android/android/myprojects/test1/jni/davinci_spi.c:32:
D:/android/android/myprojects/test1/jni/davinci_spi.h:6: error: expected specifier-qualifier-list before 'dv_reg'

注意:我使用的是 cygwin(添加了 C/C++ 编译器),而 davinci_spi.c 是一个简单的 linux 驱动程序

最佳答案

我打赌 dv_reg 没有被定义。请务必包含定义类型 dv_reg 的头文件。

关于c++ - C中的编译时错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14566627/

相关文章:

linux - ARM 上未对齐内存访问的函数

c++ - IMAGE_SECTION_HEADER的VirtualAddress和PointerToRawData的区别

c++ - 填充字符**

c++ - 计划的目的

c - 用 C 打印文件中的所有重复单词

linux - PowerShell 脚本查找文件中的特定单词并在行开头添加 “4”

c++ - 模板滥用?

c - 为指针的索引赋值

c - fgets inside while循环用于登录验证

c++ - 如何使用libevent检测文件锁何时释放?