149
submitted 1 month ago by Sunshine@piefed.ca to c/linux@programming.dev
you are viewing a single comment's thread
view the rest of the comments
[-] zygo_histo_morpheus@programming.dev 11 points 1 month ago* (last edited 1 month ago)

Making a u32 ~~pointer~~ from two u16's isn't a generic operation because it has to make assumptions about ~~how the pointers work~~ endianess

Edit: Actually, I'm wrong, didn't think this through properly. See the replies

[-] FizzyOrange@programming.dev 2 points 1 month ago

What makes you think it's making a pointer? Nobody said anything about that.

Oh my bad I don't know where I got that from lol

[-] FizzyOrange@programming.dev 3 points 1 month ago

Nw. You're also wrong about endianness. This function would be written exactly the same irrespective of endianness:

uint32_t u16_high_low_to_u32(uint16_t high, uint16_t low) {
  return (high << 16) | low;
}

That is endian agnostic.

this post was submitted on 10 Aug 2025
149 points (95.7% liked)

Linux

9572 readers
638 users here now

A community for everything relating to the GNU/Linux operating system (except the memes!)

Also, check out:

Original icon base courtesy of lewing@isc.tamu.edu and The GIMP

founded 2 years ago
MODERATORS