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?

picture of code doesn't compile

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

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -