02-06-2025, 02:55 AM
Hi! I have a question.
Are structs automatically padded during compilation? I recommend you to order your fields by size or manually padding your fields like this :
Field ordering :
Manual padding :
Are structs automatically padded during compilation? I recommend you to order your fields by size or manually padding your fields like this :
Field ordering :
Code:
typedef struct
{
typedef struct
{
int x; /*!< horizontal position */
int y; /*!< vertical position */
int width; /*!< horizontal size */
int height; /*!< vertical size */
uint16_t id; /*!< unique ID */
uint16_t gid; /*!< graphic ID (tile index) */
uint16_t flags; /*!< attributes (FLAG_FLIPX, FLAG_FLIPY, FLAG_PRIORITY) */
uint8_t type; /*!< type property */
bool visible; /*!< visible property */
char name[64]; /*!< name property */
}
TLN_ObjectInfo;
Manual padding :
Code:
typedef struct
{
uint16_t id; /*!< unique ID */
uint16_t gid; /*!< graphic ID (tile index) */
uint16_t flags; /*!< attributes (FLAG_FLIPX, FLAG_FLIPY, FLAG_PRIORITY) */
uint16_t padding;
int x; /*!< horizontal position */
int y; /*!< vertical position */
int width; /*!< horizontal size */
int height; /*!< vertical size */
uint8_t type; /*!< type property */
bool visible; /*!< visible property */
char name[64]; /*!< name property */
}
TLN_ObjectInfo;