我建立了一个工作的C库,使用常量,在头文件中定义为联盟初始化++和C
typedef struct Y {
union {
struct bit_field bits;
uint8_t raw[4];
} X;
} CardInfo;
static const CardInfo Y_CONSTANT = { .raw = {0, 0, 0, 0 } };
我知道.raw
初始化为C仅语法。
如何以这样的方式定义常量与它们中的联合,以便我可以在C和C++中使用它们。
你确定混合模式标签? – 2012-07-19 07:17:46
是不是C++初始化第一个元素的'union's?即'static const Y_CONSTANT = {{0,0,0,0}};' – YePhIcK 2012-07-19 07:19:48
@YePhIcK然后它给出了关于丢失大括号的其他警告。 – Alex 2012-07-19 07:22:06