C compiling: “defined as wrong kind of tag”

Just to help people who face this problem: If you’re compiling your C code, and then the compiler says to you something like this:

./foo.c: In function `bar':
./foo.c:158: `structure_x' defined as wrong kind of tag

Don’t panic! Take a look at the bar function.

You’re probably declaring a variable of the structure_x kind but as a different type it really is.

For example, structure_x is an enum and you did something like this:

struct structure_x my_variable;

when the correct would be:

enum structure_x my_variable;.

This post is simple, but will surely help to avoid headaches 😛

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>