[Gambas-user] VarPtr() on array syntax

Tobias Boege taboege at ...626...
Sat Feb 14 15:19:06 CET 2015


Hi Benoit,

in bug #589, comment #6, [0] you wrote that the C code

  interface = PMD_Find_Inteface ( &hid[i], i, USB1608FS_PID);

would translate to

  Const USB1608FS_PID As Integer = &H007D& ' from usb_1608FS.h
  ...
  PMD_Find_Interface(VarPtr(Hid[I]), I, USB1608FS_PID)

(Yes, we're still trying to solve this problem and the ones around it in the
 German Gambas forum where it was initially posted.)

But VarPtr() apparently cannot handle the array syntax used in its argument,
as it "takes only one identifier". See attached script which also contains a
good workaround.

Regards,
Tobi

[0] https://code.google.com/p/gambas/issues/detail?id=589

-- 
"There's an old saying: Don't change anything... ever!" -- Mr. Monk
-------------- next part --------------
#!/usr/bin/gbs3

Extern inet_aton(Ip As String, AddrOut As Pointer) As Integer In "libc:6"

Public Sub Main()
  Dim aIp As String[] = ["8.8.8.8", "192.168.1.1"]
  Dim aAddr As New Integer[2]
  Dim iAddr As Integer
  Dim iInd As Integer

  For iInd = 0 To aIp.Max
#If True
    Debug "inet_aton =";; inet_aton(aIp[iInd], VarPtr(aAddr[iInd]))
#Else
    Debug "inet_aton =";; inet_aton(aIp[iInd], VarPtr(iAddr))
    aAddr[iInd] = iAddr
#Endif
  Next
  Debug Hex$(aAddr[0]), Hex$(aAddr[1])
End


More information about the User mailing list