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

Matheus Castello matheus at castello.eng.br
Thu Oct 6 17:19:30 CEST 2022



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?)

BR,
Matheus Castello

> 
> 
> 5 ott 2022, 20:36 da benoit.minisini at gambas-basic.org:
> 
>     Le 05/10/2022 à 04:29, Matheus Castello a écrit :
> 
>         Hi guys,
> 
>         I'm new to Gambas3, I'm trying to use it for embedded devices
>         and I'm doing some external function calls. There is some way in
>         Gambas3 to get, or Gambas runtime stores, the last errno from a
>         external function call?
> 
>         I tried to get it directly from libc `__errno_location` but
>         surely the runtime must be making other calls that are
>         overwriting the errno.
> 
>         Thanks in advance,
>         Matheus Castello
> 
>         ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
> 
> 
>     The 'System.Error' property returns the value of errno.
> 
>     Regards,
> 
>     -- 
>     Benoît Minisini.
> 
> 
>     ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
> 
> 
> 
> 
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----


More information about the User mailing list