<div dir="ltr">With Allegro CL, there's an option you can pass (:error-value :os-specific) where it will give you errno or GetLastError() depending on what OS you're on.</div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Thu, Aug 15, 2013 at 12:48 PM, Mark Cox <span dir="ltr"><<a href="mailto:markcox80@gmail.com" target="_blank">markcox80@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
G'day Everyone,<br>
<div class="im"><br>
On 13/08/2013, at 6:54 AM, Luís Oliveira wrote:<br>
<br>
> How about an interface like this?<br>
><br>
> (with-errno<br>
> (some-foreign-function-with-the-errno-option-on)<br>
> (get-errno))<br>
><br>
> or perhaps<br>
><br>
> (with-errno (errno)<br>
> (some-foreign-function-with-the-errno-option-on)<br>
> errno)<br>
<br>
</div>Isn't this problem more general than just errno? For example, the functions WSAGetLastError() and GetLastError() on Windows.<br>
<br>
// On Posix based systems:<br>
ssize_t rv = read(fd, buffer, buffer_size);<br>
if (rv == -1) {<br>
printf("ERROR: %s\n", strerror(errno));<br>
return FAILED;<br>
}<br>
<br>
// On Windows (Winsock):<br>
SOCKET s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);<br>
if (s == INVALID_SOCKET) {<br>
int last_error = WSAGetLastError();<br>
WCHAR buffer[1024];<br>
FormatMessage(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_IGNORE_INSERTS,<br>
0, last_error, 0, buffer, 1024, NULL);<br>
return FAILED;<br>
}<br>
<br>
// On Windows (Named Pipes)<br>
HANDLE h = CreateFileA(pipe_name, GENERIC_READ | GENERIC_WRITE, ... );<br>
if (h == INVALID_HANDLE_ERROR) {<br>
DWORD last_error = GetLastError();<br>
WCHAR buffer[1024];<br>
FormatMessage(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_IGNORE_INSERTS,<br>
0, last_error, 0, buffer, 1024, NULL);<br>
return FAILED;<br>
}<br>
<br>
This entire thread has been enlightening.<br>
<br>
Thanks<br>
<span class="HOEnZb"><font color="#888888">Mark<br>
</font></span></blockquote></div><br></div>