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
我是按照这里的回答写的接口(interface)头文件 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* 行上收到以下错误
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 : ')'
最佳答案
尝试:
typedef struct reprVectorsTree * RHandle;
你不能只使用一个结构,就好像它是 C 中没有 typedef 的类型(例如 typedef struct reprVectorsTree;
)
编辑:您还需要 #include <stdbool.h>
对于 bool
假设你使用的是最新的 C 编译器,或者只使用 int
相反。
关于c++ - 错误 C2143 : syntax error : missing '{' before '*' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11993101/