c - .h note: previous declaration of 'QueueADT' was here typedef struct { } *QueueADT; -
i know how solve errors redefinition of typedef struct queueadt.
error messages
gcc -std=c99 -ggdb -wall -wextra -c queueadt.c queueadt.c:22:3: error: 'queueadt' redeclared different kind of symbol }*queueadt; ^ in file included queueadt.c:9:0: queueadt.h:23:21: note: previous declaration of 'queueadt' here typedef struct { } *queueadt; ^ queueadt.c:30:1: error: unknown type name 'queueadt' queueadt que_create( int (*cmp)(const void*a,const void*b) ) { ^ queueadt.c:30:10: error: conflicting types 'que_create' queueadt que_create( int (*cmp)(const void*a,const void*b) ) { ^ in file included queueadt.c:9:0: queueadt.h:44:10: note: previous declaration of 'que_create' here queueadt que_create( int (*cmp)(const void*a,const void*b) ); ^
the .h file has definition if not compiling queueadt , que_create
#ifndef _queue_impl_ typedef struct { } *queueadt; #endif queueadt que_create( int (*cmp)(const void*a,const void*b) );
now not sure how define queueadt struct , que_create .c file here
#ifndef _queue_impl_ #include "queueadt.h" struct node { void* data; //size_t num; struct node *next; }node; typedef struct queueadt { struct node *front; /* pointer front end of queue */ struct node *rear; /* pointer rear of queue */ int *contents[ queue_size ]; /* number of items in queue */ int *cmprfunc; /* compare function used insert */ }*queueadt; queueadt que_create( int (*cmp)(const void*a,const void*b) ) { struct queueadt *new; new = (struct queueadt*)malloc(sizeof(struct queueadt)); if (cmp == null) { //do create new pointer cmp_int64? new->front = null; new->rear = null; new->cmprfunc = null; } else { new->cmprfunc = &cmp; new->front = null; new->rear = null; } homecoming ( new ); }
edit 1 error message went
queueadt.c:22:3: error: 'queueadt' redeclared different kind of symbol }*queueadt; ^ in file included queueadt.c:9:0: queueadt.h:23:21: note: previous declaration of 'queueadt' here typedef struct { } *queueadt; ^ queueadt.c:30:1: error: unknown type name 'queueadt' queueadt que_create( int (*cmp)(const void*a,const void*b) ) { ^
to
in file included queueadt.c:8:0: queueadt.h:44:1: error: unknown type name 'queueadt' queueadt que_create( int (*cmp)(const void*a,const void*b) ); ^ queueadt.h:49:19: error: unknown type name 'queueadt' void que_destroy( queueadt queue ); #define queue_size 5 #include "queueadt.h" #define _queue_impl_ struct node { void* data; //size_t num; struct node *next; }node; typedef struct queueadt { struct node *front; /* pointer front end of queue */ struct node *rear; /* pointer rear of queue */ //int *contents[ queue_size ]; /* number of items in queue */ int *cmprfunc; /* compare function used insert */ }*queueadt; queueadt que_create( int (*cmp)(const void*a,const void*b) ) { struct queueadt *new; new = (struct queueadt*)malloc(sizeof(struct queueadt)); if (cmp == null) { //do create new pointer cmp_int64? new->front = null; new->rear = null; new->cmprfunc = null; } else { new->cmprfunc = &cmp; new->front = null; new->rear = null; } homecoming ( new ); }
the first line of c file
#ifndef _queue_impl_
is incorrect, should defining macro, not testing it:
#define _queue_impl_
that beingness said, there's easier way accomplish you're trying do. instead of preprocessor wrapping, can instead have single line in header:
typedef struct queueadt *queueadt;
even if struct queueadt
(n.b. different queueadt
) isn't defined, can still utilize pointer it. then, within c file, define struct queueadt
:
struct queueadt { ... };
note lack of typedef
in struct
definition.
c debugging header queue abstract-data-type
No comments:
Post a Comment