Spidfire
Spidfire

Reputation: 5523

Struct declaration error in C

ive got a struct problem it returns:

cd.h:15: error: two or more data types in declaration specifiers

its probably something simple ...

  struct cd {
        char titel[32];
        char artiest[32];
        int speelduur;  

    };

    typedef struct cd CD;
    struct cdlijst{ 
        CD *item;
        struct cdlijst *next;
    }


    typedef struct cdlijst CDLijst;

Upvotes: 3

Views: 1590

Answers (3)

ZelluX
ZelluX

Reputation: 72655

The answer is that you missed a semi-colon at the end of declaration of struct cdlijst, add a semi-colon will fixes the problem.

By the way, I would like to recommand Clang for syntax correcting, since it will give much better explanations on compiling errors. Here is an article comparing gcc and Clang on error recovery messages: http://blog.llvm.org/2010/04/amazing-feats-of-clang-error-recovery.html.

Upvotes: 3

John Marshall
John Marshall

Reputation: 7005

Some otherwise incomprehensible error messages (including this one) are due to things as simple as missing semicolons.

Upvotes: 3

Justin Ethier
Justin Ethier

Reputation: 134157

Perhaps you need a semicolon after the second struct declaration, like this:

struct cdlijst{ 
    CD *item;
    struct cdlijst *next;
};

Upvotes: 5

Related Questions