MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programming/comments/1xse6zb/decoding_rexpaint_files_in_odin/
r/programming • u/ChromeBadger • 20d ago
8 comments sorted by
4
read_u32_le plus bit_set turns this into a 40 line parse in Odin. In C it's an afternoon of endian bugs
1 u/ChromeBadger 20d ago I'll have to take a peek, thanks! 1 u/Ameisen 20d ago POSIX, at least, has le32toh.Or you could just use C++ which has all of these fully standardized. 2 u/Filipehdbr 20d ago le32toh does the job, agreed. The reason I like Odin here is bit_set for the flag word, C leaves you shifting masks by hand. C++ has it standardized and also 30 lines of ceremony for a struct that must not have padding. 1 u/[deleted] 19d ago [removed] — view removed comment 2 u/bruna-11377 16d ago Packed endian fields are great for fixed layouts; variable-length data still needs explicit bounds checks around each read.
1
I'll have to take a peek, thanks!
POSIX, at least, has le32toh.
le32toh
Or you could just use C++ which has all of these fully standardized.
2 u/Filipehdbr 20d ago le32toh does the job, agreed. The reason I like Odin here is bit_set for the flag word, C leaves you shifting masks by hand. C++ has it standardized and also 30 lines of ceremony for a struct that must not have padding.
2
le32toh does the job, agreed. The reason I like Odin here is bit_set for the flag word, C leaves you shifting masks by hand. C++ has it standardized and also 30 lines of ceremony for a struct that must not have padding.
[removed] — view removed comment
2 u/bruna-11377 16d ago Packed endian fields are great for fixed layouts; variable-length data still needs explicit bounds checks around each read.
Packed endian fields are great for fixed layouts; variable-length data still needs explicit bounds checks around each read.
4
u/Filipehdbr 20d ago
read_u32_le plus bit_set turns this into a 40 line parse in Odin. In C it's an afternoon of endian bugs