我正在尝试使用 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/