BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Unwanted include

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (IDE)
View previous topic :: View next topic  
Author Message
Jerker
Guest





PostPosted: Wed Sep 21, 2005 12:26 pm    Post subject: Unwanted include Reply with quote



Hi all! The BCB include mechanism is truly a mystery to me. It seems
like the compiler includes header files that are not mentioned in any
#include directive.

Here is the beginning of my file Xml.cpp:

#pragma hdrstop
#include "Xml.h"
.... no more includes in this file

And here is the beginning of Xml.h:

#ifndef XML_H
#define XML_H
#include <sstream>
#include <iostream>
#include <vector>
#include <map>
#include <string>
using namespace std;
.... no more includes in this file

When I compile Xml.cpp (using Alt-F9), I get a compilation error in
another header file of the project, called Utility.h. Clearly, those
five STL include files can't have any references back to Utility.h,
which I wrote myself. So why was Utility.h included in the compilation?

(You might be wondering why I just don't correct the error in
Utility.h. The problem is that there is actually nothing wrong with
Utility.h - it compiles file when used in all units that explicitly
includes it. I asked about this problem in a post a few days ago in
this forum, but have yet to find a solution.)

Using C++Builder 6 Persona,l build 10.161.

Thanks in advance!

Back to top
Jerker Hammarberg
Guest





PostPosted: Wed Sep 21, 2005 1:02 pm    Post subject: Re: Unwanted include Reply with quote



I got around the problem by explicitly including "Utility.h" before
"Xml.h" in Xml.cpp. This means that if I DON'T include a header file, I
get a compilation error in the file that I didn't include, but if I DO
include it (although it doesn't contain any declarations that I need),
it works fine. I'm still curious for an explanation to this behaviour.

/Jerker
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (IDE) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.