473,758 Members | 2,401 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2239
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-*********@yande x.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
2098
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 IsValidSession as Boolean Sub New(UserName, Password) ' Create session, including calls on DataAccess ' to validate username/password
2
4768
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 declaration statement be in? suppose I have a class A and B, sample code as following: // A.h #ifndef A_H #define A_H
4
3284
by: Henke | last post by:
I have this scenario. public class A { public int numbers; public class A() { }
1
1096
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
1224
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 one of them I need to change the
6
5076
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) in search (no record) mode. When the search is executed, frmperson calls frmsearchresult (dim f as new frmsearchresult) which is a listing of persons. From frmsearchresults, frmperson is called (dim f as new frmperson) with the resulting...
3
4412
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 really understand how this could be an issue. The assemblies that the system is complaining about are ones that we build here and we're not changing version numbers on anything. The errors come and go with no apparent rhyme or reason. We do not...
7
13524
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 dependencies). But then I started wondering how "easy" it would be to similarly make a NON-RUNTIME circular dependency between (implicitly linked) DLLs. Indeed authors like John Lakos, who focus on compile/link-time dependencies (not run-time),...
6
3472
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
9492
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9299
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10076
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9908
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9740
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8744
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6564
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3832
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.