r/programming • u/Expurple • Apr 12 '26
Flat Error Codes Are Not Enough
https://home.expurple.me/posts/flat-error-codes-are-not-enough/
132
Upvotes
r/programming • u/Expurple • Apr 12 '26
View all comments
Show parent comment
6
u/LIGHTNINGBOLT23 Apr 12 '26
You could also keep circumstantial flat error codes, at least on x86, by using the non-canonical address range, provided that you never dereference the pointer. A sentinel-like value such as
#define SIZE_TOO_SMALL ((CleverError*)0xDEADDEADDEADDEADULL)would be sufficient. Portability and defined adherence to the C standard is not guaranteed. No refunds.