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?
It needs to be like this:
Or even:
Don’t confuse type names and variables!
(By the way, Posix reserves
_tsuffixes for types, I believe…)