473,383 Members | 1,742 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,383 software developers and data experts.

Circular including, help!!

Check this out... file foo.hpp includes bar.hpp, but bar.hpp includes
foo.hpp.
The compiler/linker is having a lot of problem resolving this problem.
Does anyone know if there is a way to solve this problem.

TIA

Oct 16 '05 #1
6 2225
Post the code so we can help out.

Oct 16 '05 #2
add macro in foo.hpp
#define FOO_HPP
--------
wrap the include directive like follows in bar.hpp
#ifndef FOO_HPP
#include foo.hpp //original include directive
#endif

Oct 16 '05 #3
You may use header duards (or whatever to call them) like these:

file foo.hpp:

#ifndef _FOO_HPP_
#define _FOO_HPP_
.... dontents of foo.hpp goes here
#endif /* _FOO_HPP_ */
file bar.hpp:

#ifndef _BAR_HPP_
#define _BAR_HPP_
.... dontents of bar.hpp goes here
#endif /* _BAR_HPP_ */
and now you may include any of them in any order any number of times,
but the code will be included only once

Oct 16 '05 #4

__PPS__ wrote:
You may use header duards (or whatever to call them) like these:


guards I meant :)

you may see that inclusion of foo.hpp defines macro _FOO_HPP_, the next
time this header included once again _FOO_HPP_ will be defined and the
entire contents of it will be skiped, that's how it works. Same thing
happens with _BAR_HPP_ ...

Oct 16 '05 #5
You will need to use forward declarations to resolve the circular
includes.

The following article about header file including should help:
http://www.eventhelix.com/RealtimeMa...dePatterns.htm

--
EventStudio System Designer 2.5 - http://www.EventHelix.com/EventStudio
Sequence Diagram Based System Design and Object Modeling Tool

Oct 16 '05 #6
__PPS__ <i-*********@yandex.ru> wrote:
You may use header duards (or whatever to call them) like these:

file foo.hpp:

#ifndef _FOO_HPP_
#define _FOO_HPP_
... dontents of foo.hpp goes here
#endif /* _FOO_HPP_ */
file bar.hpp:

#ifndef _BAR_HPP_
#define _BAR_HPP_
... dontents of bar.hpp goes here
#endif /* _BAR_HPP_ */


Yes, but names starting with an underscore followed by a capital letter
are reserved for the implementation (also, names starting with two
underscores). You should remove them, like FOO_HPP and BAR_HPP.

--
Marcus Kwok
Oct 16 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Henry Miller | last post by:
I have the following code (much simplified for this post). Note that SessionKey uses DataAccess, and DataAccess requires SessionKey in it's constructor. Public Class SessionKey Public...
2
by: blueblueblue2005 | last post by:
Hi, there was a post several days ago about using forward class declaration to solve the circular including issue, today, one question suddenly came into mind: which class should the forward class...
4
by: Henke | last post by:
I have this scenario. public class A { public int numbers; public class A() { }
1
by: Diego F. | last post by:
Hello. I need to include help to a C# Windows Application. How do I start in Visual Studio 2003? Regards, Diego F.
4
by: Tiraman | last post by:
Hi , Problem description : I have 2 assemblies (A.dll And B.dll) . They are both under the GAC and they are both using the functions of each other . Each time that I m doing a change in...
6
by: Stephen Robertson | last post by:
We are currently in a dead end with a circular reference issue using vb.net, and are hoping someone might help us resolve it. Idea... We have frmmain calling frmperson (dim f as new frmperson)...
3
by: Richard Lewis Haggard | last post by:
We are having a lot of trouble with problems relating to failures relating to 'The located assembly's manifest definition with name 'xxx' does not match the assembly reference" but none of us here...
7
by: barias | last post by:
Although circular dependencies are something developers should normally avoid, unfortunately they are very easy to create accidentally between classes in a VS project (i.e. circular compile-time...
6
by: Mosfet | last post by:
Hi, I have two classes, let's call them class A and class B with mutual dependencies as shown below and where implementation is inside .h (no cpp) #include "classB.h" class A {
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.