Sorry for the title, I can't find words to describe my question in few words.
I already know that swift can use struct written in c. For example
In Bridging-Header.h
typedef struct {
int x;
int y;
} Pointer;
then I can use Pointer directly.
But in my case, I have a library written in C. There are many structs with hidden implement. For example:
In Briding-Header.h
typedef struct Pointer Pointer;
I can't use Pointer any more, got unknown type. In my library Pointer is used as
create_pointer(Pointer **pointer);
Any help is appreciated!
P.S I have no .h file which define struct Pointer. All details about Pointer is hide, access them by function, for example
int getx(Pointer *pointer);
Here is my full test code:
user_input.c
#include <stdio.h>
#include "user_input.h"
struct Pointer {
int x;
int y;
};
void get_user_input(int *user_input) {
scanf("%i", user_input);
}
void init_pointer(Pointer *point) {
point->x = 20;
point->y = 20;
}
user_input.h
#ifndef __user_input_h__
#define __user_input_h__
typedef struct Pointer Pointer;
void init_pointer(Pointer *p);
#endif
Bridging-Header.h
#include "user_input.h"
main.swift
import Foundation
var pointer:Pointer = Pointer(x:10, y:20)
Xcode give me this error: Pointer undefined