Skip to main content
edited tags; edited title
Link
Kerrek SB
  • 480.3k
  • 96
  • 904
  • 1.1k

swift Swift with cC struct pointer

added 30 characters in body
Source Link
Kerrek SB
  • 480.3k
  • 96
  • 904
  • 1.1k

I have a C struct havethat contains a pointer, all defined in a c include fileC header:

struct testA {
  int iSignal;
  struct testB *test;
   };
    
struct testB {
    int iPro;
   };

Then I have a swift fileSwift program to initialize an instance of this struct:

var a = testA()
var b = testB()
a.test = &b // this line error

But I get the following error: '&' used with non-inout argument of type 'UnsafeMutablePointer'

'&' used with non-inout argument of type 'UnsafeMutablePointer<testB>'

Anyone canCan anyone help  ?

I have a C struct have a pointer in a c include file:

struct testA {
  int iSignal;
  struct testB *test;
   };
   struct testB {
    int iPro;
   };

Then I have a swift file to initialize this struct:

var a = testA()
var b = testB()
a.test = &b // this line error

But I get error: '&' used with non-inout argument of type 'UnsafeMutablePointer'

Anyone can help  ?

I have a C struct that contains a pointer, all defined in a C header:

struct testA {
  int iSignal;
  struct testB *test;
};
 
struct testB {
  int iPro;
};

Then I have a Swift program to initialize an instance of this struct:

var a = testA()
var b = testB()
a.test = &b // this line error

But I get the following error:

'&' used with non-inout argument of type 'UnsafeMutablePointer<testB>'

Can anyone help?

Source Link
Cindy
  • 273
  • 4
  • 21

swift with c struct pointer

I have a C struct have a pointer in a c include file:

struct testA {
  int iSignal;
  struct testB *test;
   };
   struct testB {
    int iPro;
   };

Then I have a swift file to initialize this struct:

var a = testA()
var b = testB()
a.test = &b // this line error

But I get error: '&' used with non-inout argument of type 'UnsafeMutablePointer'

Anyone can help ?