Sign in to follow this  
CreepingDeath666

#define error in .h file please help

Recommended Posts

I programmed two files, one for linked lists and the other for stacks. I used my link.h file within my stack.h file because I use my linked lists for my stacks. here's my code for each: slist.h #ifndef LIST_H #define LIST_H #include <stdlib.h> typedef struct ListElmt_ { void *data; struct ListElmt_ *next; } ListElmt; typedef struct List_ { int size; int (*match)(const void *key1, const void *key2); void (*destroy)(void *data); ListElmt *head; ListElmt *tail; } List; void list_init(List *list, void (*destroy)(void *data)); void list_destroy(List *list); int list_ins_next(List *list, ListElmt *element, const void *data); int list_rem_next(List *list, ListElmt *element, void **data); #define list_size(list) ((list)->size) #define list_head(list) ((list)->head) #define list_tail(list) ((list)->tail) #define list_is_head(list, element) ((element == (list)->head ? 1 : 0) #define list_is_tail(list, element) ((element)->next == NULL ? 1 : 0) #define list_data(element) ((element)->data) #define list_next(element) ((element)->next) #endif here is the code for stack.h: stack.h #ifndef STACK_H #define STACK_H #include <stdlib.h> #include "slist.h" typedef List Stack; #define stack_init list_init #define stack destroy list_destroy int stack_push(Stack *stack, const void *data); int stack_pop(Stack *stack, const void **data); #define stack_peek(stack) ((stack->head == NULL ? NULL : (stack)->head->data) #define stack_size list_size #endif Whenever I don't comment out: #define stack_init list_init #define stack destroy list_destroy I get these errors: c:\Documents and Settings\Owner\Desktop\Programming\stack\stack.h(12) : error C2146: syntax error : missing ',' before identifier 'list_destroy' c:\Documents and Settings\Owner\Desktop\Programming\stack\stack.h(13) : error C2146: syntax error : missing ',' before identifier 'list_destroy' stack.cpp(9) : error C2146: syntax error : missing ',' before identifier 'list_destroy' stack.cpp(11) : error C2146: syntax error : missing ')' before identifier 'list_destroy' stack.cpp(11) : error C2660: 'list_ins_next' : function does not take 1 arguments stack.cpp(11) : error C2059: syntax error : ')' stack.cpp(21) : error C2146: syntax error : missing ',' before identifier 'list_destroy' stack.cpp(23) : error C2146: syntax error : missing ')' before identifier 'list_destroy' stack.cpp(23) : error C2660: 'list_rem_next' : function does not take 1 arguments stack.cpp(23) : error C2059: syntax error : ')' whenever I comment out those two lines, the program compiles with no problems. In my project, I also include list.cpp which is the implementation of slist.c. I can't figure out why I am getting these errors since I am only #define the two stack functions to equal the list functions. please help

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this