The Byte Order Fiasco

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

InfluxDB - Power Real-Time Data Analytics at Scale
Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
www.influxdata.com
featured
WorkOS - The modern identity platform for B2B SaaS
The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
workos.com
featured
  • cosmopolitan

    build-once run-anywhere c library

  • Well there's a reason universities switched to Java when teaching algorithms and containers after the 90's. C++ is a weak abstraction that encourages curiosity that steers students away from the coursework and causes their brains to melt. If I was going to teach it, I'd start with octal machine codes and work my way up. https://justine.lol/blinkenlights/realmode.html Sort of like if I were to teach TypeScript then I'd start with JavaScript. My approach to native development probably has more in common with web development than it does with modern c++ which is something I go into further detail here: https://github.com/jart/cosmopolitan/blob/4577f7fe11e5d8ef0a...

  • llvm-project

    The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.

  • Funny that compilers (e.g. clang: https://github.com/llvm/llvm-project/blob/b04148f77713c92ee5... ) might be able to do that only because someone on the compiler team has hand-coded a bswap expression detector.

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • squashfs-tools-ng

    A new set of tools and libraries for working with SquashFS images

  • FWIW there is an on various BSDs that contains "beXXtoh", "leXXtoh", "htobeXX", "htoleXX" where XX is a number of bits (16, 32, 64).

    That header is also available on Linux, but glibc (and compatible libraries) put named it instead.

    See: man 3 endian (https://linux.die.net/man/3/endian)

    Of course it gets a bit hairier if the code is also supposed to run on other systems.

    MacOS has OSSwapHostToLittleIntXX, OSSwapLittleToHostIntXX, OSSwapHostToBigIntXX and OSSwapBigToHostIntXX in .

    I'm not sure if Windows has something similar, or if it even supports running on big endian machines (if you know, please tell).

    My solution for achieving some portability currently entails cobbling together a "compat.h" header that defines macros for the MacOS functions and including the right headers. Something like this:

    https://github.com/AgentD/squashfs-tools-ng/blob/master/incl...

    This is usually my go-to-solution for working with low level on-disk or on-the-wire binary data structures that demand a specific endianness. In C I use "load/store" style functions that memcpy the data from a buffer into a struct instance and do the endian swapping. The copying is also necessary because the struct in the buffer may not have proper alignment.

    In C++ code, all of this can of course be neatly stowed away in a special class with overloaded operators that transparently takes care of everything and "decays" into a single integer and exactly the above code after compilation, but is IMO somewhat cleaner to read and adds much needed type safety.

  • SDS

    Simple Dynamic Strings library for C

  • Typical C culture, you would also expect that by now something like SDS would be part of the standard as well.

    https://github.com/antirez/sds

  • ccan

    The C Code Archive Network

  • The fallacy in the article is that anyone should code these functions. There's plenty of public domain libraries that do this correctly.

    https://github.com/rustyrussell/ccan/blob/master/ccan/endian...

  • SDL

    Simple Directmedia Layer

  • Ie how do you know the target's endianness? C++20 added std::endian. Otherwise you can use a macro like this one from SDL

    https://github.com/libsdl-org/SDL/blob/9dc97afa7190aca5bdf92...

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • C Strings and my slow descent to madness

    3 projects | news.ycombinator.com | 6 Apr 2023
  • Getting the maximum of your C compiler, for security

    3 projects | news.ycombinator.com | 31 Aug 2021
  • Squashfs turning 20, Squashfs tools 4.5 released

    3 projects | news.ycombinator.com | 24 Jul 2021
  • [PSA] If you are having problems running EAC enabled games on Steam, try running Steam through conty

    1 project | /r/voidlinux | 28 Nov 2023
  • How I got Wayland, Vulkan, and hardware acceleration working with Figma on Fedora 39.

    2 projects | /r/linux | 7 Nov 2023