c - 我的c程序出错

标签 c embedded

我正在尝试使用 C18 编译器为 pic18f4550 编译程序。我在这一行有一个语法错误:

typedef struct __attribute__ ((packed)) _USB_DEVICE_DESCRIPTOR

感谢任何建议

最佳答案

__attribute__ ((packed)) 是 GNU 扩展,不是 C 语言,此语法在 C18 中不可用。

请注意,关于结构填充,C18 编译器 documentation说:

ANSI C Standard: “The padding and alignment of members of structures (6.5.2.1).”

Implementation: Members of structures and unions are aligned on byte boundaries.

因此不需要通过编译器扩展来打包结构体成员。

关于c - 我的c程序出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17728496/

相关文章:

c - 大小 8 和其他内容的无效读取

c - 如何在 C 中使用 printf 为文本添加下划线

c - 在不使用库(stdio.h 除外)的情况下在换行符中打印每个单词的更好方法?

c - 双指针: pointer to struct member that is a pointer

embedded - 低级/嵌入式系统编程对于软件开发人员来说很难吗?

c - 为什么 malloc() 返回 null,STM32F407 上的堆需要或剩余多少?

c - 通过在另一个控制台中再次执行后台进程来结束它,如何完成?

c - 将 C 语言与 TI EZ430-RF2500 开发芯片结合使用

c - 如何理解这段DSP编程代码?

serial-port - ttyO 端口在 beagleboard-xm 的 QEMU 1.4.0 运行镜像上没有正确的端口地址