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

私はここの答えに従ってインターフェースヘッダーファイルを書きました cで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 : ')'
4

1 に答える 1

8

試す:

typedef struct reprVectorsTree * RHandle;

typedefのないCの型であるかのように構造体を使用することはできません(例typedef struct reprVectorsTree;

編集:最近のCコンパイラを使用していると仮定し#include <stdbool.h>てタイプを指定するか、代わりに使用する必要があります。boolint

于 2012-08-16T18:18:48.783 に答える