compiler errors - Code works in one Visual Studio C++ project, but not the other -
here code in question.
uint16_t get_unaligned_16(uint16_t *ptr) { #pragma pack(push, 1) struct packed { uint16_t __v; } *__p = (packed *)(ptr); #pragma pack(pop) return __p->__v; }
both projects targeting same vc++ runtime (2013).
here exact error compiler.
error c2065: 'packed' : undeclared identifier error c2059: syntax error : ')' error c2061: syntax error : identifier 'get_unaligned_32' error c2059: syntax error : ';' error c2059: syntax error : 'type' error c2065: 'packed' : undeclared identifier error c2059: syntax error : ')' warning c4013: 'get_unaligned_32' undefined; assuming extern returning int
any ideas why doesn't compile in 1 project, in another?
in c, must use word struct
struct names: struct packed
name of struct being defined. in c++, can omit keyword, here, referring (packed *)
in cast of ptr
. guess file gave errors .c file, or compiled c.
Comments
Post a Comment