[Gambas-user] Error with VarPtr() function

Brian G brian at westwoodsvcs.com
Fri Oct 29 00:47:43 CEST 2021

S is a pointer when passed to extern functions, 
So varptr does not work here
If you need a pointer do the following
Extern getptr(dst as string, src as string, len as integer) as pointer in "libc:6 exec "memcpy"
In your code
Dim s as string = "ssdffghhhjj"
Dim a as pointer = getptr(s,s,0)
It returns the actual pointer to the string....
Be very careful it does not go out of scope
Not a good idea if you don't really really know what you are doing.
Brian G Thursday, 28 October 2021, 02:52PM -07:00 from vuott--- via User  user at lists.gambas-basic.org :

>if I run this simple code:
>   Private s As String
>   Public Sub Main()
>        Dim p As Pointer
>          s = "abcde"
>          p = VarPtr(s)
>   End
>I obtain this error window message:
>« This application has raised an unexpected error and must abort.
>   System error #3: Nessun processo corrisponde (#42)
>   Design.TimerWatch_Timer.1777  »
>P.s. my system:
>Gambas=3.16.90 57916c6 (master)
>Distribution=Linux Mint 20.2 Uma
>----[  http://gambaswiki.org/wiki/doc/netiquette ]----
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20211029/fe0e76a1/attachment-0001.htm>

More information about the User mailing list