The offsetof macro seems not to work under C++/CLI.
This works fine in unmanaged C++, but throws ‘error C2275: ‘Entity’ :illegal use of this type as an expression’ error in CLI.
struct Property{ char* label; PropertyTypes type; unsigned int member_offset; unsigned int position; unsigned char bit_offset; }; struct Entity{ ... bool transparent; ... }; Property property = {'Transparent', TYPE_BOOL, offsetof(Entity, transparent), 0, 0}; // C2275 HERE
Does CLI have some replacement?
My guess would be that the compiler message boils down to: ‘offsetof’ is not a known macro and if it was a function its parameters must not contain a typename.
Edit: As somebody pointed out in the comments, offsetof is actually part of the std lib. So what’s missing is probably just
Alternatively, you can use this macro implementation (taken from Win32/MFC headers):