0

I've been able to get simple strings passed from C to dart via FFI and Native Ports with on examples like:

// Basic working example on the C side
char * str = "some string";
Dart_CObject msg;
msg.type = Dart_CObject_kString;
msg.value.as_string = (char *)str;
Dart_PostCObject_DL(dart_port, &msg)

How would you pass a pointer to a struct, for example. The idea below produces this error: Assigning to 'struct (unnamed struct from incompatible type'

// a simple struct
typedef struct {
    float * floatPtr;
    int nbrItems;
}simpleStruct;

// declare a pointer to a simple struct
simpleStruct * simpleStructPtr;

// posting to dart
Dart_CObject msg;
msg.type = Dart_CObject_kNativePointer;

 //error: Assigning to 'struct (unnamed struct from incompatible type 'simpleStruct 
msg.value.as_native_pointer  = (simpleStruct *) simpleStructPtr; 

Dart_PostCObject_DL(dart_port, &msg)
Kdigital
  • 3,795
  • 3
  • 28
  • 24

0 Answers0