Is there a way to enforce specific endianness for a C or C++ struct?

前端 未结 11 1238
南方客
南方客 2020-12-13 09:24

I\'ve seen a few questions and answers regarding to the endianness of structs, but they were about detecting the endianness of a system, or converting data between the two d

11条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-13 10:08

    No, I dont think so.

    Endianness is the attribute of processor that indicates whether integers are represented from left to right or right to left it is not an attribute of the compiler.

    The best you can do is write code which is independent of any byte order.

提交回复
热议问题