Random error occurences? [ NOT Solved]

Started by
11 comments, last by SirLuthor 19 years, 2 months ago
I'd really love to wait until my earlier thread is off the top of the list, as spam is something everyone is willing to give, but no one wants, but regrettably, time is not a resource I currently have masses of, so I'll have to post this now. I'm having a big problem. I have a project (not even near completion) which compiles fine. Now, in that project, I have a class called 'Task', in the 'ASC-Task.hpp' file, as seen here: ASC-Task.hpp

#ifndef ASC_TASK_HPP
#define ASC_TASK_HPP

#include "ASC-Define.hpp"
#include "ASC-TaskManager.hpp"
#include "ASC-Callbacks.hpp"

namespace ASC
{
	namespace Core
	{
		class Task
		{
			public:
				Task();
				virtual ~Task();

				virtual ASCCB * Update() = 0;
				virtual ASCCB * OnKill() = 0;

				friend class TaskManager;
			protected:
				void SetVals(ASCSINT id, ASCSTRING name, ASCSTRING desc);

				ASCSINT	taskID;
				ASCSTRING taskName;
				ASCSTRING taskDescription;
			private:
		};
	}
}

#endif




Now, that looks fine, is implemented (not the pure virtual functions of course..) and compiles just fine with the rest of my project. However, when I add another header file, 'ASC-EntryTask', which inherits from ASC::Core::Task, I get a host of odd syntax errors in every single file, where there were none before. And I don't mean a small amount of errors, where there were 0, now there are 646... And that seems VERY odd to me, because nothing has changed in any of the files, except adding the '#include ".\Core\ASC-EntryTask.hpp" to the shared header file that all .cpp files include. Here's an example of one of the vexing errors.. Get a load of this: error C2039: 'cout' : is not a member of 'std'. Not only that kind of error, but it's spitting out a load of syntax errors for no reason at all... Rather puzzling, to say the least. Anyway, without further ado, I give you 'ASC-EntryTask.hpp', the file which apparently is causing all my problems. ASC-EntryTask.hpp

#ifndef ASC_ENTRYTASK_HPP
#define ASC_ENTRYTASK_HPP

#include "ASC-Define.hpp"
#include "ASC-Task.hpp"

namespace ASC
{
	namespace Core
	{
		class EntryTask : public Task
		{
			public:
				EntryTask();
				~EntryTask();

				virtual ASCCB * Update() = 0;
				virtual ASCCB * OnKill() = 0;
			protected:
			private:
		};
	}
}

#endif




I really can't make anything of this, so if anyone here would be kind enough to perhaps tell me why everything is so screwed with the addition of that file, I'd be quite thankful [smile] Cheers! [EDIT] In case anyone notices the line: class EntryTask : public Task Should I include the full name there, that is, ASC::Core::Task there? Because it seems that at least for friend declarations, I can't do that, or it gives me an error. [Edited by - SirLuthor on February 9, 2005 5:10:45 AM]
Free speech for the living, dead men tell no tales,Your laughing finger will never point again...Omerta!Sing for me now!
Advertisement
Have you done:
#include <string>using namespace std;


? It seems like that is why the cout is not a member of std.

- Drew
I use no 'using' directives at all.

In case it helps, I'm getting errors before every opening and closing brace, like:
error C2143: syntax error : missing ; before {
or
error C2143: syntax error : missing ; before }
Free speech for the living, dead men tell no tales,Your laughing finger will never point again...Omerta!Sing for me now!
Sorry, I meant that you need this:
#include <iostream>using namespace std;


Brain lapse where cout was located at [lol].

[edit]Hmm, check all of the .hpp files and make sure the classes have a ; at the closing brace.

[edit]
Here is a quick reference to namespaces. I'm thinking there may be a collision with the namespace usage somehow when you add that file in. What does the define.hpp look like as well as the other one.
I have of course included <iostream>. Remember, I said that there were ZERO errors before I included that one file.
Free speech for the living, dead men tell no tales,Your laughing finger will never point again...Omerta!Sing for me now!
if your not putting it in as <iostream.h> you have to do "using namespace std".. just add a .h and it *should* work. At least, it does that on my compiler :).

~zix~
---------------------------------------------------Game Programming Resources, Tutorials, and Multimedia | Free Skyboxes
If you are using Microsoft Visual C++, (may not be the only one with this problem, but the only one I've tested it on is this one.) all standard includes (incorrect usage of term? I meant iostream and all that) HAVE to come above all of your own includes.

I've found that if you don't put standard includes first, then you will get the errors you've listed.
Quote:Original post by zix99
if your not putting it in as <iostream.h> you have to do "using namespace std".. just add a .h and it *should* work. At least, it does that on my compiler :).

~zix~


No if about it, never use <iostream.h>. And you don't have to do "using namespace std", you can just pull out the bits you're actually using or use fully qualified names. Really, they stuck everything in that neat little container to avoid conflicts, dumping everything out into the global namespace kind of defeats the whole point.
Chess is played by three people. Two people play the game; the third provides moral support for the pawns. The object of the game is to kill your opponent by flinging captured pieces at his head. Since the only piece that can be killed is a pawn, the two armies agree to meet in a pawn-infested area (or even a pawn shop) and kill as many pawns as possible in the crossfire. If the game goes on for an hour, one player may legally attempt to gouge out the other player's eyes with his King.
Drew_Benton: Regarding checking classes for missing ; Presumably, if I had a missing semi-colon somewhere, it would have been picked up by the compiler earlier, even before I added the ASC-EntryTask.hpp file in? As for ASC-define.hpp, it's just a load of #define's, like, '#define ASCCB ASC::Core::Callback', etc.

Lenox: I'll have a look and check if all my includes are ordered properly, I tend to put C++ standard includeds on top, in alphabetical order, followed by other includes, also in alphabetical order. But I'll check, hell, if that's the reason for all my errors, I'd be quite happy :)
Free speech for the living, dead men tell no tales,Your laughing finger will never point again...Omerta!Sing for me now!
Oh. my. god. I hate it when I do that... Such a simple mistake, I probably never would have found it, if not by pure chance of having encountered something sort of like this a while back, which I had forgotten about.

Apparently, the problem was this: In the shared header, Ascendancy.hpp, the ASC-EntryTask.hpp was included above the ASC-Task.hpp file, which would lead to the 'EntryTask' class inheriting from a class not even declared when EntryTask was declared..

Of course, simple beginner's mistake as it was, that was a very vexing experience.. And I still can't figure out why it borked all my curly braces [smile].... Cheers folks, and thanks for the input! Apparently, #include'ing in alphabetical order is not always the optimal setup :D
Free speech for the living, dead men tell no tales,Your laughing finger will never point again...Omerta!Sing for me now!

This topic is closed to new replies.

Advertisement