i have to impplement a dynamic stack to create a program but when i try to compile my stack.c file(with gcc) I get a bunch of errors here are my files
GLOBALS.h
#ifndef _globals
#define _globals
#define DATA( L ) ( ( L ) -> datapointer )
#define NEXT( L ) ( ( L ) -> next )
typedef enum { OK, ERROR } status ;
typedef enum { FALSE = 0 , TRUE=1 } bool ;
typedef void *generic_ptr ;
#endif
STACK.h
#ifndef _stack
#define _stack
#define STACKINCREMENT 100
#include "globals.h"
typedef struct{ generic_ptr *base; generic_ptr *top; } stack;
extern status init_stack( stack *p_S ) ;
extern bool empty_stack( stack *p_S );
extern status push( stack *p_S , generic_ptr data ) ;
extern status pop( stack *p_S , generic_ptr *p_data) ;
extern status top( stack *p_S , generic_ptr *p_data ) ;
#endif
STACK.c
#include <stdlib.h>
#include "globals.h"
#include "stack.h"
#define STACKINCREMENT 100
#define current_stacksize(p_S) ((p_S)->top - (p_S)->base)
typedef struct{
generic_ptr *base ;
generic_ptr *top ;
int stacksize ;
}stack ;
status init_stack(stack *p_S){
p_S->base = (generic_ptr *)malloc(STACKINCREMENT*sizeof(generic_ptr)) ;
if(p_S->base == NULL)
return ERROR ;
p_S->top = p_S->base ;
p_S->stacksize = STACKINCREMENT ;
return OK ;
}
bool empty_stack(stack *p_S){
return (p_S->top == p_S->base) ? TRUE : FALSE ;
}
status push(stack *p_S , genereic_ptr data){
if(current_stacksize(p_S) == p_S->stacksize){
generic_ptr *newstack = (generic_ptr *) realloc(p_S->base,(p_S->stacksize+STACKINCREMENT)*sizeof(genereic_ptr *)) ;
if(newstack == NULL)
return ERROR ;
p_S->base = newstack ;
p_S->top = p_S->base + p_S->stacksize ;
p_S->stacksize += STACKINCREMENT ;
}
*p_S->top = data ;
p_S->top++ ;
return OK ;
}
status pop(stack *p_S , generic_ptr *p_data){
if(empty_stack(p_S) == TRUE)
return ERROR ;
p_S->top-- ;
*p_data = *p_S->top ;
return OK ;
}
status top(stack *p_S,generic_ptr *p_data){
if(pop(p_S,p_data) == ERROR )
return ERROR ;
return push(p_S,*p_data) ;
}