Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/61.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C ';结构<;匿名>';没有指定成员_C_Struct_Queue_Member_Abstract Data Type - Fatal编程技术网

C ';结构<;匿名>';没有指定成员

C ';结构<;匿名>';没有指定成员,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

正在寻找引用节点并为创建函数将其设置为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':
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 */