I am trying to pack a struct into as little space as possible. I have reduced its total memory required to 104 bits, yet sizeof() says that my struct requires a whopping 28 bytes! What have I done wrong?
Next to each item I have indicated what I believe the size is, in bits.
typedef struct eval {
move best; - 56
uint8_t type; - 8
int score; - 16
uint16_t last_access_move; - 16
int depth; - 8
}
typedef struct move { - 56
coord from; - 16
coord to; - 16
piece captured; - 8
piece promote_to; - 8
uint8_t c; - 8
} move;
typedef struct piece { - 8
char type; - 4
bool white; - 4
} piece;
typedef struct coord { - 16
uint8_t col; - 8
uint8_t row; - 8
} coord;