[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.
--
Thanks
Brian G Thursday, 28 October 2021, 02:52PM -07:00 from vuott--- via User  user at lists.gambas-basic.org :

>Hello,
>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  »
>
>regards
>vuott
>
>P.s. my system:
>
>Gambas=3.16.90 57916c6 (master)
>OperatingSystem=Linux
>Kernel=5.11.0-38-generic
>Architecture=x86_64
>Distribution=Linux Mint 20.2 Uma
>Desktop=Cinnamon
>Font=Ubuntu,10
>Scale=7
>Theme=mint-y
>Language=it_IT.UTF-8
>Memory=5380M
>
>[Libraries]
>Cairo=libcairo.so.2.11600.0
>Curl=libcurl.so.4.6.0
>DBus=libdbus-1.so.3.19.11
>GDK2=libgdk-x11-2.0.so.0.2400.32
>GDK3=libgdk-3.so.0.2404.16
>GStreamer=libgstreamer-1.0.so.0.1602.0
>GTK+2=libgtk-x11-2.0.so.0.2400.32
>GTK+3=libgtk-3.so.0.2404.16
>OpenGL=libGL.so.1.7.0
>Poppler=libpoppler.so.97.0.0
>QT5=libQt5Core.so.5.12.8
>SDL=libSDL-1.2.so.0.11.4
>SQLite=libsqlite3.so.0.8.6
>
>----[  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