A ton of repeating error messages

I just spent the past few days trying to put A* in my roguelike. For some reason it just took a minute to click. Anyways, after I was done, I hit compile. All of a sudden I have tons of errors. I go through them, a few missing semi-colons, fix them, compile, and still tons of errors. Mostly 4 of them, repeating, and saying its different lines of code, through all of my source files. But, here's the thing. I never changed any of the code that its referring to since the last successful compile. Here are the errors:
1
2
3
4
list.h(77): error C2143: syntax error : missing ';' before '*'
list.h(77): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
list.h(77): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
list.h(77): warning C4183: 'get_monster': missing return type; assumed to be a member function returning 'int'

And here's a snippet:
1
2
3
	int how_many() { return num_of_mons; }
	Character * get_monster() { return current_node->get_char(); } <-- line 77
	bool find( int X, int Y );


All the errors are of my Character class. Which is included, and, as I said, worked fine before. And all of the errors are for code I haven't touched. I went through my code and spent a day trying to find answers on Google, but I guess I don't know what to search for, because nothing I've found describes this problem.

So. I decided to delete all the path finding code I had put in. After all, I've figured it out, and that was the hard part. So, now my code is in the exact same state as it was last time it compiled.But, it still doesn't compile. Can anyone tell me what I've done and how I can fix it? I'm using Visual 2010 Express.
99% of the errors are false positive,
The only error that is probably correct is first one.

what is the first error you see in "show errors"?
solve first error and all other errors (most probably) will gone.

sintax error may also be in a header file or template inside a header that is being included in current header, so check that too.
closed account (4z0M4iN6)
Did you take care, that the compiler understands the data type "Character"?
Maybe you could use "char" instead?
Last edited on
I'm pretty sure his "Character" is not a char primitive type, but a class signifying a game Character.

@OP:
Tip: never add an algorithm to working code before testing it first. It's very difficult to debug things if you have to test everything at once.
closed account (4z0M4iN6)
Gaminic wrote:
I'm pretty sure his "Character" is not a char primitive type, but a class signifying a game Character.

I simply don't know, what "Character" means. I don't need to know. But the compiler needs to know!
I'd wager that his Character class definition is missing a terminator after the closing bracket.
closed account (4z0M4iN6)
Could be also.

So you should also look, whether your "Character" is well defined.
Last edited on
Just saw an error like this in another thread:
http://cplusplus.com/forum/beginner/70288/

Note that it's semicolon related, in that case it was an extra semicolon. It may be lines before the line that it reports the error on.

Keep back tracking looking for something like }; where there shouldn't be or a missing semicolon where there should be.
Last edited on
Thanks for the feedback. I've checked through my code again, and all I'm not missing, nor do I have extra, semicolons.

@codekiddy: First error is :
1
2
3
4
list.h(28): error C2143: syntax error : missing ';' before '*'
list.h(28): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
list.h(28): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
list.h(28): warning C4183: 'get_char': missing return type; assumed to be a member function returning 'int'


Referring to get_char. It also gives the same errors for the me pointer. And, as I've said before, this is in code I haven't changed.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
class monster_node
{
public:
	monster_node();

	Character * get_char();
	monster_node * get_prev();
	monster_node * get_next();

	void set_next( monster_node * ptr_next );
	void set_prev( monster_node * ptr_prev );

	void create();
	void remove();
	void set( int ID, int X, int Y );

private:
	Character * me;
	monster_node * prev;
	monster_node * next;

};


The only headers I'm using are ones that I've written, SDL.h, SDL_image.h, string, cstdlib, time.h, and fstream. Except for the ones I've written, which I've checked and look right, I've been using these libraries since before the last working compile.

@dadabe: Character is defined, the compiler has never had a problem with the class before, and it was one of the first classes I put in.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
header:
#ifndef CHARACTER_H
#define CHARACTER_H

#include "SDL.h"
#include "init.h"
#include "Map.h"
#include "list.h"
#include <string>
#include <fstream>
#include <cstdlib>

class Character
{
public:
	Character();
	void set_Up(int set_x, int set_y, int set_ID );
	int get_Color() { return color; }
	int get_BGcolor() { return bg_color; }
	char get_Tile() { return tile; }
	int get_X() { return location.X; }
	int get_Y() { return location.Y; }

	void move( int delt_X, int delt_y );
	void save( std::ofstream &file );
	void load( std::ifstream &file );
	
	int process_Turn();
	coord path_request();
	

private:
	int color, bg_color, creatureID;
	coord location, destination;
	char tile;
	void set_attrib();
	
};

#endif

and source:
#include "character.h"

Character::Character()
{
}

void Character::set_Up( int set_x, int set_y, int set_ID )
{
	location.X = set_x;
	location.Y = set_y;
	creatureID = set_ID;
	set_attrib();

	
}

void Character::move( int delt_X, int delt_Y )
{
	location.X += delt_X;
	location.Y += delt_Y;
}

void Character::set_attrib()
{
	switch ( creatureID )
	{
	case PC_ID:
		color = PC_COLOR;
		bg_color = PC_BG;
		tile = PC_TILE;
		break;

	case GOB_ID:
		color = GOB_COLOR;
		bg_color = GOB_BG;
		tile = GOB_TILE;
		break;

	case DOG_ID:
		color = DOG_COLOR;
		bg_color = DOG_BG;
		tile = DOG_TILE;
		break;
	}
}

void Character::save( std::ofstream &file )
{
	file << location.X << " " << location.Y << " " << creatureID << " ";
}

void Character::load( std::ifstream &file )
{
	file >> location.X;
	file >> location.Y;
	file >> creatureID;
	set_attrib();
}

coord Character::path_request()
{
	if( location == destination)
	{
		coord newdest;
		newdest.X = rand() % ( WORLD_X - 1 );
		newdest.Y = rand() % ( WORLD_Y - 1 );
		destination = newdest;
		return newdest;
	}

	return destination;
}

int Character::process_Turn()
{
	//Poll current state

	//Decide what to do
	if( creatureID != PC_ID ) //PCs don't have to plan turns
	{
		/*if( !move_plan.move_again() )
			return MON_PATH;

		return MON_MOVE;*/

	}

	return MON_NOTHING;
}


@iHutch105: A terminator? What do you mean? All the references I see when I google terminator c++ are to using NULL to end strings and arrays. If I add class to the search I just get information about some Terminator class someone wrote.
bhazothemad,

Please post the list.h
as you see the problem is there.
First off, I apologize for lack of comments, I believe understandable variables makes readable code, let me know if you want me to comment anything, but its just a straightforward double linked circular list. It has worked before.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
the header:
#ifndef LIST_H
#define LIST_H

#include <SDL.h>
#include <fstream>
#include "character.h"


class monster_node
{
public:
	monster_node();

	Character * get_char();
	monster_node * get_prev();
	monster_node * get_next();

	void set_next( monster_node * ptr_next );
	void set_prev( monster_node * ptr_prev );

	void create();
	void remove();
	void set( int ID, int X, int Y );

private:
	Character * me;
	monster_node * prev;
	monster_node * next;

};


class monster_list
{
public:
	monster_list();
	void add( int ID, int X, int Y );
	void remove();
	void forward();
	void backward();
	void reset();
	void start();
	void save( std::ofstream &file );
	void load( std::ifstream &file );
	int how_many() { return num_of_mons; }
	Character * get_monster() { return current_node->get_char(); }
	bool find( int X, int Y );

private:
	monster_node * root_node;
	monster_node * current_node;
	int num_of_mons;
};

#endif 

and the source:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
#include "list.h"

monster_node::monster_node()
{
	me = NULL;
	prev = NULL;
	next = NULL;
}

Character * monster_node::get_char()
{
	return me;
}

monster_node * monster_node::get_prev()
{
	return prev;
}

monster_node * monster_node::get_next()
{
	return next;
}

void monster_node::set_next( monster_node * ptr_next )
{
	next = ptr_next;
}

void monster_node::set_prev( monster_node * ptr_prev )
{
	prev = ptr_prev;
}

void monster_node::create()
{
	next = NULL;
	prev = NULL;
	me = new Character;
}

void monster_node::remove()
{
	delete me;
	next = NULL;
	prev = NULL;
	me = NULL;
}

void monster_node::set( int ID, int X, int Y )
{
	me->set_Up( X, Y, ID );
}



monster_list::monster_list()
{
	root_node = NULL;
	current_node = NULL;
	num_of_mons = 0;
}

void monster_list::add( int ID, int X, int Y )
{
	if( root_node == NULL )
	{
		root_node = new monster_node;
		root_node->create();
		root_node->set( ID, X, Y );
		num_of_mons++;
	}

	else if( root_node->get_prev() == NULL )
	{
		current_node = new monster_node;
		current_node->create();
		current_node->set( ID, X, Y );
		current_node->set_next( root_node );
		current_node->set_prev( root_node );
		root_node->set_next( current_node );
		root_node->set_prev( current_node );
		num_of_mons++;
	}

	else
	{
		monster_node * temp_node = root_node->get_prev();
		current_node = new monster_node;
		current_node->create();
		current_node->set( ID, X, Y );
		current_node->set_next( root_node );
		current_node->set_prev( temp_node );
		root_node->set_prev( current_node );
		temp_node->set_next( current_node );
		num_of_mons++;
	}
}

void monster_list::remove()
{
	if( current_node != root_node )
	{
		if( current_node->get_next() == root_node && current_node->get_prev() == root_node)
		{
			delete current_node;
			current_node = root_node;
			root_node->set_next( NULL );
			root_node->set_prev( NULL );
			num_of_mons--;
		}
		else
		{
			monster_node * temp_node = current_node->get_prev();
			temp_node->set_next( current_node->get_next() );
			temp_node = current_node->get_next();
			temp_node->set_prev( current_node->get_prev() );
			current_node->remove();
			delete current_node;
			current_node = root_node;
			num_of_mons--;
		}
	}

	else 
	{
		if( current_node->get_prev() == NULL )
		{
			current_node->remove();
			delete current_node;
			root_node = NULL;
			current_node = NULL;
			num_of_mons = 0;
		}
		else
		{
			monster_node * temp_node = current_node->get_next();
			if( temp_node->get_next() == current_node )
			{
				root_node->remove();
				delete root_node;
				root_node = temp_node;
				root_node->set_next( NULL );
				root_node->set_prev( NULL );
				current_node = root_node;
				num_of_mons--;
			}

			else
			{
				temp_node->set_prev( current_node->get_prev() );
				current_node->remove();
				delete current_node;
				current_node = temp_node;
				root_node = temp_node;
				temp_node = root_node->get_prev();
				temp_node->set_next( root_node );
				num_of_mons--;
			}
		}
	}
}

void monster_list::forward()
{
	monster_node * temp_node = current_node;
	current_node = temp_node->get_next();
}

void monster_list::backward()
{
	monster_node * temp_node = current_node;
	current_node = temp_node->get_prev();
}

void monster_list::reset()
{
	if( root_node == NULL )
		return;

	monster_node * temp_node = root_node->get_prev();
	current_node = temp_node;
	while( current_node != root_node )
	{
		temp_node = current_node->get_prev();
		current_node->remove();
		delete current_node;
		current_node = temp_node;
	}

	root_node->remove();
	delete root_node;
	root_node = NULL;
	current_node = NULL;
	num_of_mons = 0;
}

void monster_list::start()
{
	current_node = root_node;
}

bool monster_list::find( int X, int Y )
{
	current_node = root_node;

	for( int i = 0; i < num_of_mons - 1; i++ )
	{
		if( current_node->get_char()->get_X() == X && current_node->get_char()->get_Y() == Y )
			return true;
		else 
		{
			current_node = current_node->get_next();
		}
	}

	return false;
}

void monster_list::save( std::ofstream &file )
{
	file << num_of_mons << " ";
	current_node = root_node;
	
	for( int i = 0; i < num_of_mons; i++ )
	{
		current_node->get_char()->save( file );
		forward();
	}
}

void monster_list::load( std::ifstream &file )
{
	file >> num_of_mons;
	monster_node * temp;
	for( int i = 0; i < num_of_mons; i++ )
	{
		temp = new monster_node;
		temp->create();
		temp->get_char()->load( file );
		if( root_node == NULL )
		{
			root_node = temp;
		}
		else
		{
			temp->set_prev( current_node );
			current_node = temp;
		}
	}
	current_node->set_next( root_node );
}

Last edited on
closed account (4z0M4iN6)
You wrote some kind of a poem!

If you didn't see what could be wrong, you should have a look at the beginning of your character.h file. The 4th include will explain it - and remember my words, the compiler should know, what Character means.

I would suggest, you rethink some includes, maybe less includes would bring the solution, can you see this? Also could be - I only took 2 looks, that there isn't a solution, if you do it like this.

What happens?

Your source includes list.h
list.h includes characters.h
characters.h includes list.h
and list.h don't know

Sounds like a poem.
What do you think about my poem, which you can find in my profile?
Last edited on
bhazothemad,

Please do this:

Inside your List.h remove this inclusion:
#include "character.h"

and replace it with this:

class Character;


inside your list.cpp file write this:

#include "character.h"

Report the results here.
It worked. But... its always been set up like that. And its compiled like that several times before.

What caused this? This has gotten me all sorts of confused.
It worked. But... its always been set up like that. And its compiled like that several times before.

It has been set up in a wrong way because you should know that inclusion of headers must be avoided in other headers at all cost's.

That is the rule of thumb and every programer whether bad or good one knows that, so did you too but for some reason you didn't care about that isn'it?

I'm glad you solve the problem btw.
closed account (4z0M4iN6)
And nobody is interested in my poems
Topic archived. No new replies allowed.