gcc says me:
cc -O3 -Wall -pedantic -g -c init.c
init.c:6:1: error: two or more data types in declaration specifiers
init.c: In function 'objinit':
init.c:24:1: warning: control reaches end of non-void function
make: *** [init.o] Error 1
the code is:
#include "beings.h"
#include "defs.h"
#include "funcs.h"
#include "obj.h"
void objinit(int type, struct object* lstrct){
switch(type){
case WALL:
lstrct->image = WALL_IMG;
lstrct->walk = false;
lstrct->price = 0;
break;
case WAND:
lstrct->image = WAND_IMG;
lstrct->walk = true;
lstrct->price = 70;
break;
case BOOK:
lstrct->image = BOOK_IMG;
lstrct->walk = true;
lstrct->price = 110;
break;
}
}
i know, things like WALL_IMG is on a .h separated file, but whats wrong with my code?
My psychic debugging powers tell me that it is likely you have a struct definition in obj.h
that is not terminated with a semicolon.
Incorrect:
struct object { /* etc. */ }
Correct:
struct object { /* etc. */ };
Why do I think this? The errors say:
init.c:6:1: error: two or more data types in declaration specifiers
init.c: In function 'objinit':
init.c:24:1: warning: control reaches end of non-void function
The warning says the compiler thinks your function has a non-void return type, yet your function is clearly declared with a void
return type. The error says that the compiler thinks your function is declared with multiple types. The most likely explanation is that there is a struct definition in obj.h
that is unterminated.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With