Does GCC's __attribute__((__packed__)) retain the original ordering?

前端 未结 6 1463
执念已碎
执念已碎 2020-12-01 10:46

Purpose

I am writing a network program in C (specifically gnu89) and I would like to simplify things by reinterpreting a certain

6条回答
  •  我在风中等你
    2020-12-01 11:02

    Based on what you're trying to do, I'd highly encourage you to also used fixed-size data types (ie. uint32_t, int16_t, etc) that are found in stdint.h. Using fixed-size data types will prevent you from having to do things like the following:

    struct name
    {
        short field : 8;
    };
    

提交回复
热议问题