This code is for implementing generic stack functionality in C.
Code for stack.h
-------------
typedef struct{
void *elements;
int elementSize;
int logofElementsLength;
int allocatedLength;
}stack;
bool stackEmpty(const stack *s);
code for implementation in Client.c
bool stackEmpty(const stack *s)
{return (s->logLength==0);
}
Error
error: expected '=', ',', ';', 'asm' or '__attribute__' before 'stackEmpty'
Comments
The code compiles otherwise and I only get an error on this line. Obviously the error must emanate from this line of code. I am using
gcc -O0 -g3 -Wall -arch i386 -c -fmessage-length=0 -MMD -MP
-MF"Client.d" -MT"Client.d" -o"Client.o" "../Client.c"
to compile.
I am running on MAC Snow Leopard OS. I have imported stack.h in my Client.c and all other code compiles and runs fine. Any help would be appreciated.
Well, unlike in C++,
boolis not a valid type in C (unless usingstdbool.hof course). I’ve seenboolused this way in C: