错误C2143:语法错误:在'*'之前缺少'{'

时间:2012-08-16 18:16:46

标签: c++ c

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

我根据这里的答案编写了接口头文件 How to use c++ objects in c? ,但我得到语法错误?缺少什么?

---- ----编辑 我把它改成了

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

现在我在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 : ')'

1 个答案:

答案 0 :(得分:8)

尝试:

typedef struct reprVectorsTree * RHandle;

你不能只使用一个结构,好像它是一个没有typedef的C类型(例如typedef struct reprVectorsTree;

编辑:假设您使用的是最新的C编译器,或者仅使用#include <stdbool.h>,您还需要bool类型int

相关问题