parameter has incomplete type in C

c, compiler-errors, enums, incomplete-type

Solution

It needs to be like this:

enum mips_opcode { add = 0, addu, sub, subu }; // type name is "enum mips_opcode"
typedef enum mips_opcode mips_opcode_t;        // type alias

Or even:

typedef enum { add = 0, addu, sub, subu } mips_opcode_t; // alias of anon. type

Don't confuse type names and variables!

(By the way, Posix reserves `_t` suffixes for types, I believe...)

Problem

I'm writing some code, when I'm trying to test my code till now, I get an error. Here is my code: ``` #include <stdio.h> enum { add = 0, addu, sub, subu } mips_opcode; typedef enum mips_opcode mips_opcode_t; typedef unsigned char byte; // 8-bit int struct mips { char *name; byte opcode; }; typedef struct mips mips_t; void init (mips_t *out, char *name_tmp, mips_opcode_t opcode_tmp) { out->name = name_tmp; out->opcode = (byte)opcode_tmp; } int main (void) { pritnf("no error i assume\n"); return 0; } ``` and the error in the commmand-line is: ``` main.c:14:55: error: parameter 3 ('opcode_tmp') has incomplete type ``` Can't I use enums as parameter or what am I doing wrong here?

Original source