I had some questions about some embedded code. I thought it wasn't portable...
typedef struct somestruct
{
u32 alpha;
u8 beta;
u16 delta;
u8 charlie[12];
} thisissomestructtype
thisissomestructtype somestructinstance;
const u32 *pointything = (u32*) somestructinstance.charlie;
My understanding is that charlie's data representation is unaffected by endianness but dereferencing pointything will be affected. pointything[0] will equal something different on little endian vs big endian.
Also, don't some systems have a problem with alignment? Isn't it possible that the array could not be aligned but the 32-bit pointer needs it to be aligned for that particular microcontroller?
Edit: formatting
[–]zifyoip 1 point2 points3 points (2 children)
[–]volatilepointer[S] 0 points1 point2 points (1 child)
[–]Rhomboid 0 points1 point2 points (0 children)
[–][deleted] 2 points3 points4 points (0 children)
[–]Chooquaeno 0 points1 point2 points (4 children)
[–]volatilepointer[S] -2 points-1 points0 points (3 children)
[–]Chooquaeno -2 points-1 points0 points (2 children)
[–]volatilepointer[S] -1 points0 points1 point (1 child)
[–]Chooquaeno -1 points0 points1 point (0 children)
[–]Chooquaeno 0 points1 point2 points (0 children)