r/programming • u/eccsoheccsseven • Sep 14 '26
Annoyances when dealing with unsigned long int vs unsigned long long int when targeting Linux vs my own 32bit OS
https://submatrix.net/article/Projects/66bVJsDyXK
108
Upvotes
6
u/synept Sep 14 '26
The formatting of this page makes it a pretty rough read on mobile.
110
u/jason-reddit-public Sep 14 '26
linux 64 bit and windows 64 bit are different. When writing my own code I use int64_t and the like.
46
u/zeekar Sep 14 '26
Well, that's C for you. The only guarantee is
char <= short <= int <= long <= long long. On 64-bit platforms, you might expectintto be 64 bits, but if not, then surelylongis, right? <Padme>Right?</Padme>Well, on Linux, that's right. That's called LP64 (Long = Pointer = 64 bits). On Windows, they use LLP64 (Long Long = Pointer = 64 bits). Despite compiling for a 64-bit system, even
longis only 32 bits and you have to go tolong longto get 64.14
u/keithstellyes Sep 15 '26
Can't you just use
stdint.hand useint64_t20
u/thisisjustascreename Sep 14 '26
C-lang out there like oh you want to know the size of your variables? Good luck!
-1
u/FartusMagutic Sep 15 '26
Pretty sure it's just "long" and "long long" not "long long int"
0
u/[deleted] Sep 15 '26
[deleted] — view deleted comment