[Gambas-bugtracker] Bug #2261: EXTERN function call does not work with Struct ?
bugtracker at gambaswiki.org
bugtracker at gambaswiki.org
Mon Jun 14 21:44:33 CEST 2021
http://gambaswiki.org/bugtracker/edit?object=BUG.2261&from=L21haW4-
Comment #1 by Brian G:
Here is an example of how to define the extern calls to use structures, and pointers
Public Struct newit
x[20] As Byte
End Struct
Public Struct byeit
c As Integer
b As Float
e[20] As Struct Newit
End Struct
Public Struct Hello
b As Integer
c As Integer
d As Long
e As Float
f As Struct Byeit
g[20] As Struct Byeit
End Struct
' We will use memcpy for two purposes , get the real address of the data, actually copy the data
' The structure must be defined before we define our externals
Extern memcpy(dest As Hello, src As Hello, len As Integer) As Pointer In "libc:6"
Extern Arraymemcpy(dest As Pointer, src As Pointer, len As Integer) As Pointer In "libc:6" Exec "memcpy"
Gambas does convert to pointers but the parameter type must be defined correctly.
More information about the Bugtracker
mailing list