包装C结构

时间:2016-07-14 00:49:29

标签: c struct

我正在尝试将结构打包到尽可能小的空间中。我已将其总内存减少到104位,但sizeof()表示我的结构需要高达28个字节!我做错了什么?

在每个项目旁边,我已经指出我认为大小是多少。

 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;

0 个答案:

没有答案
相关问题