This page is a single technical write-up on sebsite, a personal site, documenting an unconventional method for retrieving the value of errno from outside C. The author frames it as a “cursed” experiment made some time ago, with the explicit goal of portability across libc implementations and no reliance on a C wrapper function.
The core problem is that errno is defined as a macro whose expansion is implementation-specific and carries no stability guarantees. When calling libc functions from another language, such as Hare in the examples shown, there is normally no portable way to read the error value afterward. The post walks through the constraints before presenting the hack itself.
The technique relies on symbol-level tricks rather than a clean API, so it suits programmers already comfortable with linking, symbols, and ABI behavior. Readers who just want a supported errno accessor will not find one here; the value is in the reasoning and the demonstration of what is possible at the boundary between languages.
Use it as a reference for understanding errno’s portability pitfalls and for seeing how far one can push interposition in practice. Treat the approach as an experiment to learn from rather than production guidance, and verify behavior against your target libc before adopting anything similar.
Comments & Ratings
0No comments yet. Be the first to review.