当担心字节顺序? [英] When to worry about endianness?

查看:137
本文介绍了当担心字节顺序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我所看到的字节排列顺序以及这意味着什么无数引用。我没有这方面的问题?
然而,我的编码项目是一个简单的游戏在Linux和Windows上运行,在标准的游戏玩家的硬件。
我需要担心在这种情况下字节顺序?当我应该需要担心吗?
我的code是简单的C和SDL + GL,唯一复杂的数据是基本的媒体文件(PNG + WAV + XM)和游戏数据大多是串,整数布尔(为标志等等)和静态大小的数组。到目前为止,没有用户已经有问题,所以我想知道如果加入的检查是必要的(将在后面做的,但更多的是紧迫的问题IMO)。

I have seen countless references about endianness and what it means. I got no problems about that... However, my coding project is a simple game to run on linux and windows, on standard "gamer" hardware. Do I need to worry about endianness in this case? When should I need to worry about it? My code is simple C and SDL+GL, the only complex data are basic media files (png+wav+xm) and the game data is mostly strings, integer booleans (for flags and such) and static-sized arrays. So far no user has had issues, so I am wondering if adding checks is necessary (will be done later, but there are more urgent issues IMO).

推荐答案

如果你的意思是标准的玩家的硬件一台PC,那么你不必担心字节顺序,因为它总是会在x86 / x64的小尾数。但是,如果你想将这个项目到其他架构,那么你应该字节顺序,独立设计的。

If you mean a PC by "standard gamer hardware", then you don't have to worry about endianness as it will always be little endian on x86/x64. But if you want to port the project to other architectures, then you should design it endianness-independently.

这篇关于当担心字节顺序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆