Can I safely assume that Windows installations will always be little-endian?

前端 未结 2 1692
-上瘾入骨i
-上瘾入骨i 2020-12-05 17:54

I\'m writing a userspace filesystem driver on Windows and endianness conversions are something I\'ve been dealing with, as this particular filesystem always stores values in

相关标签:
2条回答
  • 2020-12-05 18:23

    All versions of Windows that you'll see are little-endian, yes. The NT kernel actually runs on a big-endian architecture even today.

    0 讨论(0)
  • 2020-12-05 18:25

    Edit after changed question:

    A) No it is not necessary to check endianness if your sole target is Windows x86 or x64. I wouldn't even spend the time checking the endianness in that case.

    B) If you want to check bi-endian support of your code I recommend splitting it into libraries that are themselves cross platform compilable. Then compile and run the code on your favorite Linux flavor that supports big-endian and see if it works. I have yet to hear of any compiler or software that can detect bi-endian issues.

    Original response:

    As far as I'm aware there are no desktop or server versions of windows that support big-endian. Itanium processors (which I believe were always called IA 64, not IA32 but I could be wrong) have the ability to run in big-endian but Windows doesn't support it.

    This isn't to say that Windows 8 will be little-endian only as Windows 8 is targeting ARM processors.

    If for some reason you are on Windows (#ifdef _WIN32) and big-endian simply reverse the data structures when you load from disk and just always save in little-endian format which is much more common.

    0 讨论(0)
提交回复
热议问题