0
struct reprVectorsTree;

#ifdef __cplusplus
extern "C" {
#endif

typedef reprVectorsTree * RHandle;
RHandle create_reprVectorsTree(float **, int , int );
void free_reprVectorsTree(RHandle);
float*  work_decode(RHandle , bool*, int);

#ifdef __cplusplus
}
#endif

I wrote the interface header file according to the answer here How to use c++ objects in c? , but I get the syntax error? what is missing?

----edit---- I changed it to

struct reprVectorsTree;

#ifdef __cplusplus
extern "C" {
#endif

typedef struct reprVectorsTree * RHandle;
RHandle create_reprVectorsTree(float **, int , int );
void free_reprVectorsTree(RHandle);
float*  work_decode(RHandle , bool *, int);

#ifdef __cplusplus
}
#endif

now I get the following error on the float* line

error C2143: syntax error : missing ')' before '*'
error C2081: 'bool' : name in formal parameter list illegal
error C2143: syntax error : missing '{' before '*'
error C2059: syntax error : ','
error C2059: syntax error : ')'
Community
  • 1
  • 1

1 Answers1

8

Try:

typedef struct reprVectorsTree * RHandle;

You can't just use a struct as if it's a type in C without a typedef (e.g. typedef struct reprVectorsTree;)

EDIT: You'll also need to #include <stdbool.h> for the bool type assuming you're using a recent C compiler, or just use an int instead.

James M
  • 18,506
  • 3
  • 48
  • 56