473,385 Members | 1,645 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Problems with cross references

Hello all,

I have been facing a problem for several weeks with my C++ code. First of all, I am going to expose how my files/classes are written:

File ./SimulationManager/Simulation.h (with Simulation.cc in the same location, defining the functions)
Classes:
  • IControlSimulation (virtual)
  • InputSimulation : IControlSimulation -->contains a reference to IOutput (through InputSimulation, SimulationEvents and OutputManager)

File ./Console/Console.h (idem with Console.cc)
Classes:
  • IOutput(virtual)
  • ConsoleOutputManager : IOutput (Contains a reference to IControlSimulation)

Now, let us see the code of thes classes. Please, look at the forward declarations (points A and B)

Console.h:
Expand|Select|Wrap|Line Numbers
  1. #include "../simulationManager/Simulation.h"
  2.  
  3. class IOutput{
  4.     public:
  5.         //Opens the necessary files for the execution given a filename.
  6.         virtual int openFiles(){};
  7. ...
  8. };
  9.  
  10. //class IControlSimulation; [A]
  11. //class InputSimulation; [B]
  12. class ConsoleOutputManager : public IOutput{
  13.     private:
  14.         //Control simulation
  15.         IControlSimulation *control;
  16. ...
  17.  
  18.     public:
  19.         ConsoleOutputManager(){
  20.             control = new InputSimulation();
  21.         }
  22. ...
  23. };
  24.  
  25.  
Simulation.h:
Expand|Select|Wrap|Line Numbers
  1.  
  2. #include "../console/Console.h"
  3.  
  4. class IControlSimulation{
  5. public:
  6.     //Stops the simulation
  7.     virtual void stopSimulation(){}
  8. ....
  9. };
  10.  
  11. class InputSimulation : public IControlSimulation{
  12. private:
  13.  
  14.     //Event manager
  15.     SimulationEvents * simulator;
  16. ...
  17. };
  18.  
  19. class SimulationEvents{
  20. private:
  21.     //Output manager
  22.     OutputManager * output;
  23. ...
  24. };
  25.  
  26. class OutputManager{
  27. private:
  28.     //Console for output
  29.     IOutput * console;
  30. ...
  31. public:
  32.     OutputManager(){
  33.         console = new ConsoleOutputManager();
  34.     }
  35. ....
  36. };
  37.  
  38.  
So, when I try to compile this code (with declarations A and B comented) I get the following error:

In file included from console/Console.h:11,
from console/Console.cc:1:
console/../simulationManager/Simulation.h:19: error: ISO C++ forbids declaration of `IOutput' with no type
console/../simulationManager/Simulation.h:19: error: expected `;' before '*' token
console/../simulationManager/Simulation.h: In constructor `OutputManager::OutputManager()':
console/../simulationManager/Simulation.h:26: error: `console' undeclared (first use this function)
console/../simulationManager/Simulation.h:26: error: (Each undeclared identifier is reported only once for each function it appears in.)
console/../simulationManager/Simulation.h:26: error: `ConsoleOutputManager' has not been declared
make[1]: *** [build/Release/GNU-Generic/console/Console.o] Error 1


If I let point A ("class IControlSimulation;"), the error is the following (I suppose this is obvious...):

In file included from console/Console.h:11,
from console/Console.cc:1:
console/../simulationManager/Simulation.h:19: error: ISO C++ forbids declaration of `IOutput' with no type
console/../simulationManager/Simulation.h:19: error: expected `;' before '*' token
console/../simulationManager/Simulation.h: In constructor `OutputManager::OutputManager()':
console/../simulationManager/Simulation.h:26: error: `console' undeclared (first use this function)
console/../simulationManager/Simulation.h:26: error: (Each undeclared identifier is reported only once for each function it appears in.)
console/../simulationManager/Simulation.h:26: error: `ConsoleOutputManager' has not been declared
make[1]: *** [build/Release/GNU-Generic/console/Console.o] Error 1


And finally, with both lines uncommented:

In file included from console/Console.h:11,
from console/Console.cc:1:
console/../simulationManager/Simulation.h:19: error: ISO C++ forbids declaration of `IOutput' with no type
console/../simulationManager/Simulation.h:19: error: expected `;' before '*' token
console/../simulationManager/Simulation.h: In constructor `OutputManager::OutputManager()':
console/../simulationManager/Simulation.h:26: error: `console' undeclared (first use this function)
console/../simulationManager/Simulation.h:26: error: (Each undeclared identifier is reported only once for each function it appears in.)
console/../simulationManager/Simulation.h:26: error: `ConsoleOutputManager' has not been declared
make[1]: *** [build/Release/GNU-Generic/console/Console.o] Error 1



Maybe the error is too obvious, but I cannot see it. If anybody could help me to solve it I would be very thankful.

Thank you all for your time (including the time spent reading this post :) )

Best regards,

Diego.
Jun 25 '07 #1
2 1526
weaknessforcats
9,208 Expert Mod 8TB
This error:
[quote=akilascartas]
console/../simulationManager/Simulation.h:19: error: ISO C++ forbids declaration of `IOutput' with no type
[/code]

says there is a problem on line 19 of Simulation.h.

This must be fixed first.

The addtional errors become less and less meaningful as the compiler becomes more an more confused.

You fix the first error. The rebuild. Then fix the first error. Then rebuild, etc.
Jun 25 '07 #2
The point is that this error comes from Console

In file included from console/Console.h:11,
from console/Console.cc:1:
console/../simulationManager/Simulation.h:19: error: ISO C++ forbids declaration of `IOutput' with no type


I mean, I think that the compiler compiles first Console (indeed it does), it reaches the "#include "../simulationManager/Simulation.h"" clause and it goes to Simulation.h before reaching IOutput in Console.h. Then, I suppose IOutput is unknown when it is compiling the OutputManager class (which contains IOutput) and this error is get.

I have just tried to make a forward declaration of IOutput (and ConsoleOutputManager, its subclass) and I get again this error:

In file included from console/Console.h:11,
from console/Console.cc:1:
console/../simulationManager/Simulation.h: In constructor `OutputManager::OutputManager()':
console/../simulationManager/Simulation.h:29: error: invalid use of undefined type `struct ConsoleOutputManager'
console/../simulationManager/Simulation.h:16: error: forward declaration of `struct ConsoleOutputManager'


Maybe the forward declarations were put before in the wrong side (declaring Simulator on Console side), but now the errors are the same :(

Thank you.

Diego
Jun 26 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: peter | last post by:
Hello all, Recently I've started to refactor my code ...(I'm using python 2.3.4) I tried to add extra functionality to old functions non-intrusively. When I used a construct, which involves...
2
by: Ryan Gregg | last post by:
I'm having a major problem with assembly references that I keep running into, and I'm really hoping that someone can help me out. The problem occurs when I have three projects in my solution, two...
10
by: BBFrost | last post by:
We just recently moved one of our major c# apps from VS Net 2002 to VS Net 2003. At first things were looking ok, now problems are starting to appear. So far ... (1) ...
19
by: Dales | last post by:
I have a custom control that builds what we refer to as "Formlets" around some content in a page. These are basically content "wrapper" sections that are tables that have a colored header and...
7
by: Scott M. | last post by:
How can I disable the cross-site scripting check for one particular page of a site?
5
by: moondaddy | last post by:
I'm setup with a new ISP where we were given an account which we could setup multiple domains. To do this we were given a root directory where we setup a folder for each domain. then we mapped...
5
by: Bryan | last post by:
I am trying to get to a label control to get its Text value. from a previous page. The label control is buried in a Web User Control that is in a webpart zone. When I use this code:...
11
by: Steve Smith | last post by:
I have written a winforms application that launches approximately 150 threads with Thread.ThreadStart() Each thread uses CDO 1.21 to logon to a different Exchange mailbox and send/receive a...
6
by: brandon.e.taylor | last post by:
I am looking for a tool capable of producing HTML pages from source files written in different languages, where the source written in one language is a port of the source written in another...
0
by: Peter Duniho | last post by:
On Mon, 02 Jun 2008 17:14:31 -0700, NvrBst <nvrbst@gmail.comwrote: The general rule is that if it's not one of the five members listed in the docs (under Control.Invoke and other pages), you...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.