Portable data reinterpretation

前端 未结 5 984
温柔的废话
温柔的废话 2020-11-30 09:28

I want to reinterpret data of one type as another type in a portable way (C99). I am not talking about casting, I want a reinterpretation of some given dat

5条回答
  •  独厮守ぢ
    2020-11-30 09:35

    the data type int is an example of a non-portable type since endianness can change byte order between platforms.

    if you want to be portable you need to define your own types, then implement them on each platform that you want to port to. Then define conversion methods for your data types. That is as far as I know the only way to have full control of byte orders etc.

提交回复
热议问题