c++ - union Initializer "error: expected primary-expression before ‘.’ token" -
i'm trying compile c code c++ compiler written else, got "error: expected primary-expression before ‘.’ token." how initialize union in case? in advance.
union v16b { v16qi v; uint8_t b[16]; uint32_t dw[4]; }; union v8w { v8hi v; int16_t w[8]; }; union v2qw { v2di v; uint64_t uq[2]; }; static inline void sd(v16qi a, v16qi b, v16qi c, v16qi d, uint16_t local_mean[4], int16_t *response) { const union v16b 0 = { .b = { 0 }}; const union v16b shuf = { .b = { 0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15 }}; ...... }
c++ not support initialization designators. statement
const union v16b 0 = { .b = { 0 }};
has syntax error in c++.
this syntax adopted in c. either compile program c-program or change definition according syntax of c++.
if need initialize data member write constructor. example
union v16b { v16b() : b { 0 ) {} v16qi v; uint8_t b[16]; uint32_t dw[4]; };
Comments
Post a Comment