I try to wrap a c library in swift package named Test.
The code looks like this:

Test1.h

struct MyParams {
int (*func)();
};

typedef struct MyParams MyParams;

Test2.h
#include "Test1.h"

static int test(){
  return 0;
}

void myTest()
{
MyParams params;
params.func = test;
}


Then I try to import the package into swift code and use
in Test.swift.
************************
import Test

class TestSwift {
  func runtest(){
    myTest()
  }
}

However, the compiler report link error:
function myTest: error: undefined reference to 'test'

If I comment out
"params.func = test;" in myTest.

It successfully build. How should I handle this situation?

Thanks,

Yang
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to