santook
Member
Can B4R support operations like AddressOf, so that in inline C, you can use Pointers to pass functions or other types?
Object objects use wrapNumber, not wrapPointer, by default.
Object objects use wrapNumber, not wrapPointer, by default.
B4X:
#Region Project Attributes
#AutoFlushLogs: True
#CheckArrayBounds: True
#StackBufferSize: 600
#End Region
'Ctrl+Click to open the C code folder: ide://run?File=%WINDIR%\System32\explorer.exe&Args=%PROJECT%\Objects\Src
Sub Process_Globals
Public Serial1 As Serial
Private wifi As ESP8266WiFi
End Sub
Private Sub AppStart
Dim o As Object
Serial1.Initialize(115200)
Log("AppStart")
'example of connecting to a local network
If wifi.Connect2("NantongCorona", "14725836") Then
Log("Connected to network")
Else
Log("Failed to connect to network")
End If
o=fun1
'Like this
'o=AddressOf(fun1)
RunNative("gofun1",o)
End Sub
Private Sub fun1()
Log("Hello World!")
End Sub
#if C
void gofun1(B4R::Object* o)
{
void (*p)();
p=(void(*)())o->data.PointerField;
p();
}
#End If