开发者

error: expected '=', ',', ';', 'asm' or '__attribute__' before 'stackEmpty'

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 Leopa开发者_C百科rd 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++, bool is not a valid type in C (unless using stdbool.h of course). I've seen bool used this way in C:

typedef enum { false, true } bool;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜