Windows API - GetLastError woes

Esa Ilari Vuokko eivuokko at gmail.com
Mon Aug 28 09:15:28 EDT 2006


Brian Hulley wrote:
>> The only way to solve this problem seems to be to wrap all
>> calls in C-functions that take care of reading GetLastError.
>> Not that it's impossible, just very annoying.
> 
> If there is no better solution, would it be possible on failure to
> somehow enter a critical section and repeat the call that caused the
> failure and then call get last error and exit the critical section so
> that normal calls would be fast but only failed calls would be slow?

In some (many) cases, yes, but for example with async IO you really
don't want to do this.  Some "errors" still cause async notification.

Gut instinct tells me repeating system calls might also cause atomicity
issues, but I don't have an example.

Best regards,
--Esa


More information about the Glasgow-haskell-users mailing list