定义函数时出现C错误"too many basic types"
C error "too many basic types" when defining a function
我正在尝试创建一个二叉树。我正在尝试编写一个将新节点插入树中的函数。它有两个参数:父节点和新节点。
struct node {
int value;
struct node * left;
struct node * right;
void (*insert)( struct node*, struct node*);
}
void treeInsert( struct node* this, struct node* new){//this is the line that gives the error
if ( new->value < this->value ){//this will insert it into the left one
if (this->left == NULL){
this->left = new;
} else {
this->left->insert( this->left, new);
}
} else {//this will insert it into the right one
if (this->right == NULL){
this->right = new;
} else {
this->right->insert( this->right, new);
}
}
}
当我使用 TCC 编译时出现错误:error: too many basic types
我不知道 TCC,但 gcc 警告说 struct
末尾缺少分号。
b.c:10:1: error: expected ‘;’, identifier or ‘(’ before ‘void’
void treeInsert( struct node* this, struct node* new){...
struct node {
int value;
struct node * left;
struct node * right;
void (*insert)( struct node*, struct node*);
};
有了那个分号,gcc 编译它没有错误和警告。
我正在尝试创建一个二叉树。我正在尝试编写一个将新节点插入树中的函数。它有两个参数:父节点和新节点。
struct node {
int value;
struct node * left;
struct node * right;
void (*insert)( struct node*, struct node*);
}
void treeInsert( struct node* this, struct node* new){//this is the line that gives the error
if ( new->value < this->value ){//this will insert it into the left one
if (this->left == NULL){
this->left = new;
} else {
this->left->insert( this->left, new);
}
} else {//this will insert it into the right one
if (this->right == NULL){
this->right = new;
} else {
this->right->insert( this->right, new);
}
}
}
当我使用 TCC 编译时出现错误:error: too many basic types
我不知道 TCC,但 gcc 警告说 struct
末尾缺少分号。
b.c:10:1: error: expected ‘;’, identifier or ‘(’ before ‘void’ void treeInsert( struct node* this, struct node* new){...
struct node {
int value;
struct node * left;
struct node * right;
void (*insert)( struct node*, struct node*);
};
有了那个分号,gcc 编译它没有错误和警告。