The author describes a hacky technique for portably accessing errno from non-C languages like Hare without using C wrapper functions. Since errno is typically a compiler/implementation-specific macro with no stability guarantees, the approach exploits perror's behavior of reading errno internally to capture error strings through stderr redirection.
Background
errno is a POSIX mechanism for reporting errors from C library functions, but its implementation varies across platforms. Languages like Hare that interface with libc face challenges accessing errno without platform-specific code or C interop wrappers.
- Source
- Lobsters
- Published
- Oct 23, 2026 at 05:42 AM
- Score
- 5.0 / 10