[Gambas-user] Get last errno from external function call

Matheus Castello matheus at castello.eng.br
Fri Oct 7 02:37:44 CEST 2022



On 10/6/2022 12:46 PM, Benoit Minisini wrote:
> Le 06/10/2022 à 17:23, Benoit Minisini a écrit :
>> Le 06/10/2022 à 17:19, Matheus Castello a écrit :
>>>
>>>
>>> On 10/5/2022 8:30 PM, vuott--- via User wrote:
>>>> Out of curiosity, maybe you could also try "System.GetExternSymbol ()":
>>>>
>>>>     Dim p As Pointer
>>>>
>>>>     p = System.GetExternSymbol("libgpiod", "errno")
>>>>
>>>>     Print Int@(p)
>>>>
>>>>
>>>
>>> What I was doing previously was getting the pointer reference calling 
>>> `__errno_location`: 
>>> https://gist.github.com/microhobby/245022469ffbcea1a07a7579839d90a2#file-main-module-L13
>>>
>>> That works too. What is actually overwriting the errno is the IDE's 
>>> Debug session ...
>>> If you try to run in the IDE debugger this will not work, this will 
>>> return 0 always. (Could you check if its reproducible in your side 
>>> please?)
>>>
>>
>> I can modify the debugger so that is saves and restore 'errno'.
>>
> 
> Done in master.
> 

Awesome! I get it from master, compiled and tested. Thanks for the quick 
fix.

BR,
Matheus Castello


More information about the User mailing list