Giter Club home page Giter Club logo

Comments (2)

Archaemic avatar Archaemic commented on May 18, 2024

This appears to be an issue with the 8 byte endian swapping functions in Endianness.h

https://github.com/cuberite/cuberite/blob/master/src/Endianness.h#L5
https://github.com/cuberite/cuberite/blob/master/src/Endianness.h#L16

These implementations unconditionally swap the top and bottom 4 bytes, which only makes sense on little endian platforms. Adding an #ifdef __BIG_ENDIAN__ and then just passing the parameter through in that block will fix it. MSVC doesn't support that, but I don't think there are any big endian platfoms that MSVC compiles to so that doesn't really matter.

from cuberite.

indrora avatar indrora commented on May 18, 2024

The big question is: Why are you reimplementing a standard library call?

ntohll and friends exist in Win32's winsock.h, while on POSIX systems (really "linux and friends") you want the calls out of <endian.h>: htobe64 and be32toh.

Furthermore: C++20 now introduces std::endian (docs) which would be a good option (constexpr values are evaluated by the compiler and linker, making this a zero-cost runtime choice).

from cuberite.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.