08 Feb, 2011, Thinoth wrote in the 1st comment:
Votes: 0
Hey guys,
Well I came here for a bit of help. I have been in the process of making a project off and on for about 4 years now. I finally got it ready and was about to put it on a server and see if I could staff it and get a player base going. It compiled and ran in windows with cygwin however when I tried it on an updated system it didnt want to go. So I am hoping you all can help me get the code up to par with the most current definitions and stuff. The first error I come across is

cygwin said:
error: array type has an incomplete element type


This is one of the 200 or so lines of code that it rejects under that premise:

extern	const 	struct	size_type	size_table[];


I know that the array is size_table[] and the compiler is telling me that the error is there, however a similar line of code that works is this:

extern	const		int		progress_table[];


The diference is the "int" where the "struct" is. I also have lines that work with "char*" in that spot. This makes me think that the error is actually with the "struct" keyword. If anyone can let me know what my problems are and why it would be greatly appreciated.
08 Feb, 2011, David Haley wrote in the 2nd comment:
Votes: 0
It means that struct size_type is not defined when the compiler sees the array declaration. You can forward-declare the structure, or make sure that the structure has been defined already.
08 Feb, 2011, Thinoth wrote in the 3rd comment:
Votes: 0
Well first and formost thank you for the responce. And well I am not entirely sure how to do that.

#define struct size_type

That just caused more problems than cygwin would display at a time and

#define size_type
or
#define size_table

just returned "expected identifier or '<' before 'Well first and formost thank you for the responce. And well I am not entirely sure how to do that.

#define struct size_type

That just caused more problems than cygwin would display at a time and

#define size_type
or
#define size_table

just returned "expected identifier or '<' before '[' token" which I usually know how to fix but < shouldn't fit in this function. Any more help?
08 Feb, 2011, Kaz wrote in the 4th comment:
Votes: 0
Hi, Thinoth, and welcome.

I have three things that may help you.

1) until you know your compiler better, pick only the first error and deal with that. Further errors may be consequences of the first. Assuming you have done so, I'll move on.

2): You seem unfamiliar with the struct keyword and some facets. If I assume too much, please skip this and go to 3). The struct keyword is used to introduce collections of variables that are passed around the program as a group. For example:

struct foo
{
int bar;
char baz;
};

int some_function(struct foo *f)
{
f->bar = 1;
f->baz = 'x';
}


If I were to make an array of 10 ints, and an array of 10 struct foos, then their definitions would look like this:

int int_array[10];
struct foo foo_array[10];


If I were to say, "elsewhere in a different module of code that you will be linked to during compilation, there will be these structures, and they will be constant," they would look like this:

extern const int int_array[];
extern const struct foo foo_array[];


From this, we can see that the code you posted is not necessarily wrong. Which brings us to:

3) incomplete types. In C, it is possible to forward-declare a type. For example:

typedef struct foo;
typedef struct size_type;


Until a definition of these is seen by the compiler (such as in 2) above), it is considered incomplete. Its internal size is unknown, and its internal variables (like bar and baz above) are unknown, so the compiler can do very little with it. In fact, all it can really do is handle pointers to that type. Now, when declaring an array of variables, the compiler must know the size of its elements so that it can step over them correctly. Since it doesn't have that size, the compiler complains at you.

So, one way to correct the problem is to define struct size_type. This is usually done by adding a #include to a header file where the structure is defined. Alternatively, you can provide the definition yourself in a similar fashion to 2) above, but it is a best practice to have a structure defined in only one place.
09 Feb, 2011, Thinoth wrote in the 5th comment:
Votes: 0
Once again thank you, that was very informative and possibly made some progress. I am now getting different errors, although only just slightly different.

I think that given your responce I may have not given enough information. Cygwin says exactly:
cygwin said:
In file included from act_com.c:42:
Merc.h:956: warning: useless storage class specifier in empty decleration
Merc.h:960: error: array type has incomplete element type
Then that same error repetes about 200 times.


Now, line 956 of merc.h is what I included:

typedef struct weapon_rate_type;

This is producing the useless storage class specifier warning

Line 960 of merc.h is
extern	const	       struct 	weapon_rate_type	weapon_rating[WEAPON_MAX];

I apologize for using a different example, it was not the first error, rather I thought it was the simplest of the errors to explain while still producing the same error. In addition I figured that if I could fix that error the skills would be transferable and I would be able to fix all of them. Again I apologize for the confusion I may have caused in trying to fix my own problem.

the variable WEAPON_MAX is defined in line 953 of merc.h
struct weapon_rate_type is also coded in merc.h as a series of variables however the table is not producing errors… yet (that means dont worry about it yet right?)
09 Feb, 2011, Kaz wrote in the 6th comment:
Votes: 0
I want to apologise, because I misstated a language feature in my post above, which is responsible for your Merc.h:956 warning. A forward declaration does not require typedef, although it can (but only with an additional alias):

/* forward declaration of struct weapon_rate_type */
struct weapon_rate_type;
/* Now you can manipulate pointers (only) to the incomplete struct weapon_rate_type. */

/* forward declaration of struct weapon_rate_type that has an alias */
typedef struct weapon_rate_type foobar;
/* Now you can write "foobar" wherever (except for the definition itself) you could write "struct weapon_rate_type" */

/* Complete the definition of struct weapon_rate_type */
struct weapon_rate_type
{
int foo;
int bar;
};
/* Now you can use struct weapon_rate_type anywhere */


However, as I said above, if you're declaring an array of struct weapon_rate_type, you cannot use an incomplete type. The contents of the struct must be known. I'm guessing that struct weapon_rate_type is defined below the array declaration. Move the defintion to above the array declaration.
09 Feb, 2011, Zeno wrote in the 7th comment:
Votes: 0
I've moved this to the C/C++ section. You'd probably also want to mention your codebase.
11 Feb, 2011, Thinoth wrote in the 8th comment:
Votes: 0
Well I want to give a big thank you to everyone who helped out with that problem. It was much appreciated and that problem has been solved.

Currently I use Flcodebase3.1 but I will also be updating the codebase itself and re-upload the new working one when it is fixed and current. Thank you once again.
0.0/8