How to set structure element at desired offset
问题 In embedded programming when describing the hardware one often needs to place struct elements at known predefined positions as the HW engineer designed them. For example, let's define a structure FPGA, which has some 100 registers/areas as in the following simplified example: struct __attribute__ ((__packed__)) sFPGA { uchar Spare1[0x24]; ushort DiscreteInput; uchar Spare2[0x7A]; //CPLD_Version is required to be at offset 0xA0, so 0xA0-0x24-2=0x7A ushort CPLD_Version; }; Now, I am frustrated