Skip to content

Cannot initialize a variable of type 'PTExampleTextFrame *' (aka '_PTExampleTextFrame *') with an rvalue of type 'void *' #47

@anonym24

Description

@anonym24

Example for iOS works ok, but when I'm trying to use libs in my own project (swift version with objective-c++ .mm classes bridges) I get next error:

Cannot initialize a variable of type 'PTExampleTextFrame *' (aka '_PTExampleTextFrame *') with an rvalue of type 'void *'

in this function (Peertalk Example) PTExampleProtocol.h

also this header file for Mac target/project, so does why iOS target/project reference to it?

static dispatch_data_t PTExampleTextDispatchDataWithString(NSString *message) {
  // Use a custom struct
  const char *utf8text = [message cStringUsingEncoding:NSUTF8StringEncoding];
  size_t length = strlen(utf8text);
  //CFAllocatorAllocate(nil, 1 + length, 0);
  PTExampleTextFrame *textFrame = CFAllocatorAllocate(nil, sizeof(PTExampleTextFrame) + length, 0);
  memcpy(textFrame->utf8text, utf8text, length); // Copy bytes to utf8text array
  textFrame->length = htonl(length); // Convert integer to network byte order
  
  // Wrap the textFrame in a dispatch data object
  return dispatch_data_create((const void*)textFrame, sizeof(PTExampleTextFrame)+length, nil, ^{
    CFAllocatorDeallocate(nil, textFrame);
  });

screenshot at apr 13 16-18-13

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions