C ';结构<;匿名>';没有指定成员
正在寻找引用节点并为创建函数将其设置为null的方法。从给定的输出中有没有建议将队列中的前后节点设置为NULLC ';结构<;匿名>';没有指定成员,c,struct,queue,member,abstract-data-type,C,Struct,Queue,Member,Abstract Data Type,正在寻找引用节点并为创建函数将其设置为null的方法。从给定的输出中有没有建议将队列中的前后节点设置为NULL gcc -std=c99 -ggdb -Wall -Wextra -c queueADT.c queueADT.c:13:1: warning: useless storage class specifier in empty declaration [enabled by default] }; ^ queueADT.c: In function 'que_create': q
gcc -std=c99 -ggdb -Wall -Wextra -c queueADT.c
queueADT.c:13:1: warning: useless storage class specifier in empty declaration [enabled by default]
};
^
queueADT.c: In function 'que_create':
queueADT.c:36:6: error: 'struct <anonymous>' has no member named 'front'
new->front = NULL;
^
queueADT.c:37:6: error: 'struct <anonymous>' has no member named 'rear'
new->rear = NULL;
^
queueADT.c:38:8: error: expected identifier before '*' token
new->*cmprFunc = NULL;
typedef结构节点{..
struct QueueADT{//body};
更改为typedef struct
{//body}QueueADT;
QueueADT new;
应该是QueueADT*new;
等等在我看来这是无效的:
struct QueueADT new;
new = (QueueADT)malloc(sizeof(struct QueueADT));
if (cmp == NULL) {
//do I create a new pointer to the cmp_int64?
new->front = NULL;
...
也许你需要这个:
struct QueueADT *new;
new = (struct QueueADT*)malloc(sizeof(struct QueueADT));
if (cmp == NULL) {
//do I create a new pointer to the cmp_int64?
new->front = NULL;
...
和:
struct QueueADT {
struct node front; /* pointer to front of queue */
struct node rear; /* pointer to rear of queue */
int *contents[ QUEUE_SIZE ]; /* number of items in queue */
int *cmprFunc; /* The compare function used for insert */
};
应该是
struct QueueADT {
struct node *front; /* pointer to front of queue */
struct node *rear; /* pointer to rear of queue */
int *contents[ QUEUE_SIZE ]; /* number of items in queue */
int *cmprFunc; /* The compare function used for insert */
};
和此处的typedef
没有意义,应将其删除:
typedef struct node {
void* data;
//size_t num;
struct node *next;
};
其他问题:struct QueueADT
中的这两个声明在我看来很可疑:
int *contents[ QUEUE_SIZE ]; /* number of items in queue */
int *cmprFunc; /* The compare function used for insert */
typedef struct node{…};
我想你的意思是int*cmprFunc(struct node*,struct node*)
My.h文件的QueueADT写得像'typedef struct{}*QueueADT;'no常量void*是抽象数据type@arrowinfedex:头文件typedef
是一个匿名结构,如*QueueADT
,但C文件定义了一个struct QueueADT
,其成员为front
和reart
,两者都是完全不同的结构new->front
不能设置为NULL代码>因为成员声明为struct node front;
(不是指针)My.h文件的QueueADT编写方式类似于typedef struct{}*QueueADT
,这会导致错误QueueADT.h:23:21:错误:“QueueADT”typedef struct{}*QueueADT;^QueueADT.c:21:3:注意:前面的'QueueADT'声明在这里}*QueueADT^
@arrowinfedex使用此信息更新您的问题。
int *contents[ QUEUE_SIZE ]; /* number of items in queue */
int *cmprFunc; /* The compare function used for insert */