a hacky fucked up way to portably access errno from outside of c

29 points by seb


jklowden

If you have a current version of the GCC source code, in libgcobol/posix you will find the beginnings of COBOL bindings for POSIX functions. Let’s just say I got there ahead of you.

We created a posix-errno function to return the value and, optionally, the string. There’s some debate about how to write to errno, which as you know is seldom necessary but unavoidable when it is. So that’s not currently available.

Yes, every integer value and struct needs a shim. SEEK_SET, say, and the struct for stat(2) are defined by the C header files. They have no standard binary representation. Two C compilers could and do use different definitions. Any language that, um, seeks to use the POSIX API is therefore obliged to create an interface-to-the-interface: to define every macro and struct in terms of the source language, and map them onto the values defined by the local friendly C compiler.