I've got a header file, and it's accompanying .c file, both of which work fine if I use them in one program. When I compile them linked to another, I get the following:
Code:
gameutils.h:7: two or more data types in declaration of 'rnumber'
What ........es me off about this whole thing is that it works flawlessly in another program:
gcc -Wall -o successtest successtest.c gameutils.c
The identical usage generates errors when I try and use it elsewhere:
gcc -Wall -o game game.c gameutils.c
Hell, I can even do it seperately:
gcc -Wall -c -o gameutils.o gameutils.c
... no errors or warnings
gcc -Wall -c -o game game.c
... error here
Header:
Code:
#ifndef GAMEUTILS
#define GAMEUTILS
#define UNMin 1
#define UNMax 10000
extern int rnumber( int, int );
extern int success( int, int );
#endif
The only difference I can see in the two would be executables is the call to rnumber.
The first uses integers returned by atoi, and it works fine.
The second uses enum values from non-typed enums:
Code:
enum
{
Foo = 1,
Bar = 5,
....
};
Then the call:
int x = rnumber( foo, bar );
Google gives me jack. Mainly people asking for the same fix.
Also, if I cange the #defines to an enum statement:
Code:
enum { UNMin = 1, UNMax = 10000 };
I get:
Code:
two types specified in one empty declaration
What really angers me here is that in one program, I get neither of these problems. In the second, both show up.
Any ideas?
Quzah.