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 

#include ??????

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





PostPosted: Tue Jul 26, 2005 1:40 am    Post subject: #include ?????? Reply with quote



Hi,
To determine what was dependent upon an included header file,
I temporarily deleted the Include file for the header.

Then I compiled and there were no errors???

Then I noticed there was another #Include for the same file.
So I deleted it and repeated the above process with the same results???!!

What's up?? I deleted all the #Includes and they were all added back.

How do I stop this? I would like to determine the dependency of an
item and I need to not include its header!

Thanks,
Wayne











Back to top
Ed Mulroy
Guest





PostPosted: Tue Jul 26, 2005 10:42 am    Post subject: Re: #include ?????? Reply with quote



Try going into Project|Options and turning off use of cached precompiled
headers.

.. Ed

Quote:
Wayne wrote in message
news:42e5a4f3$1 (AT) newsgroups (DOT) borland.com...
Hi,
To determine what was dependent upon an included header file, I
temporarily deleted the Include file for the header.

Then I compiled and there were no errors???

Then I noticed there was another #Include for the same file.
So I deleted it and repeated the above process with the same results???!!

What's up?? I deleted all the #Includes and they were all added back.

How do I stop this? I would like to determine the dependency of an item
and I need to not include its header!



Back to top
Wayne
Guest





PostPosted: Tue Jul 26, 2005 5:30 pm    Post subject: Re: #include ?????? Reply with quote



Thanks Ed,

But it didn't help...

I set the Project|Options to None (this apparently caused the Project.tds
file to be deleted) and the #Includes keep coming back.

I delete 'em, and they come back!!!

Weird and a bit eerie,
Wayne

----- Original Message -----
Quote:
Try going into Project|Options and turning off use of cached precompiled
headers.

. Ed




Back to top
Jonathan Benedicto
Guest





PostPosted: Tue Jul 26, 2005 5:45 pm    Post subject: Re: #include ?????? Reply with quote

"Wayne" <DeWire (AT) Concentric (DOT) Net> wrote

Quote:
I delete 'em, and they come back!!!

Weird and a bit eerie,
Wayne

It isn't really weird. BCB is a RAD IDE, that needs includes to make code
it writes, compile. Eg. the very basic VCL app has a header like this:

class TForm1 : public TForm
....

Now, TForm needs the Forms.hpp include otherwise it will not compile. So,
BCB provides for this, and automatically puts in the necessary includes for
you. If you remove them, BCB will put them back, in-case you deleted them
by mistake.

I know that BCB sometimes includes files un-necessarily, but it shouldn't
make that much difference to compile time.

I personally just leave them.

Jonathan



Back to top
Wayne
Guest





PostPosted: Tue Jul 26, 2005 6:38 pm    Post subject: Re: #include ?????? Reply with quote

Thanks again,

I understand the function of Include files.

I was just being whimsical with my "Weird" comment.

But I didn't know that there was an automatic feature to add #Include files.
When I fail to add one, I expect, and usually get, an error message.

This is the first situation that I have encountered where one is added
automatically for me. And pardon me but that came as a surprise, and as I
said, a bit Weird.

If the compiler is capable of determining which Include file is needed (and
has some feature to add it automatic for me), why do I have to add the
#Include for it to avoid an error message?

The question is not, "what are Include files for?", but how do I control the
feature that causes one to be added back after I delete it?

Wayne




"Jonathan Benedicto" <incorrect (AT) no (DOT) server> wrote

Quote:
"Wayne" <DeWire (AT) Concentric (DOT) Net> wrote in message
news:42e67346$1 (AT) newsgroups (DOT) borland.com...
I delete 'em, and they come back!!!

Weird and a bit eerie,
Wayne

It isn't really weird. BCB is a RAD IDE, that needs includes to make code
it writes, compile. Eg. the very basic VCL app has a header like this:

class TForm1 : public TForm
...

Now, TForm needs the Forms.hpp include otherwise it will not compile. So,
BCB provides for this, and automatically puts in the necessary includes
for you. If you remove them, BCB will put them back, in-case you deleted
them by mistake.

I know that BCB sometimes includes files un-necessarily, but it shouldn't
make that much difference to compile time.

I personally just leave them.

Jonathan




Back to top
Jonathan Benedicto
Guest





PostPosted: Tue Jul 26, 2005 7:11 pm    Post subject: Re: #include ?????? Reply with quote

"Wayne" <DeWire (AT) Concentric (DOT) Net> wrote

Quote:
If the compiler is capable of determining which Include file is needed
(and has some feature to add it automatic for me), why do I have to add
the #Include for it to avoid an error message?

In this case, AFAIK, it isn't the compiler that is adding the includes.
AFAIK, the IDE adds them as "preset" includes.

Quote:
The question is not, "what are Include files for?", but how do I control
the feature that causes one to be added back after I delete it?

I don't know. When I encountered this feature, I just gave up trying to
reduce the includes BCB puts in.

Jonathan



Back to top
Jeff Weir
Guest





PostPosted: Tue Jul 26, 2005 8:28 pm    Post subject: Re: #include ?????? Reply with quote

Wayne wrote:
Quote:
Thanks again,

The question is not, "what are Include files for?", but how do I control the
feature that causes one to be added back after I delete it?


Delete the #includes with some other editor and then compile the
project from the command line. I know this doesn't answer the question
directly but I think it kind of accomplishes what you want.

jeff

Back to top
Wayne
Guest





PostPosted: Tue Jul 26, 2005 10:53 pm    Post subject: Re: #include ?????? Reply with quote

Thanks to all, Ed, Jonathan, and Jeff,

You have all been helpful and I appreciate.it.

My original problem has been resolved by other methods,
but I would still like to resolve the question,
"how do I control the feature that causes an #Include to be added back after
I delete it?".

Other then that, all the above leads me pursue a couple of new issues.
------------------------
Jeff wrote:
Quote:
Wayne wrote:
The question is not, "what are Include files for?", but how do I control
the feature that causes one to be added back after I delete it?

Delete the #includes with some other editor and then compile the project
from the command line. I know this doesn't answer the question directly
but I think it kind of accomplishes what you want.

Thanks jeff, that seems like a good suggestion.

But as I said, I have resolved my original problem and I no longer need you
suggested work around.

Still, with respect to your suggestion, I might have a little trouble
selecting appropriate options for the compiler command.

Do you know if there is a good way to get the IDE to generate a command
without running the compiler?

------------------------
And Jonathan wrote:
Quote:
In this case, AFAIK, it isn't the compiler that is adding the includes.
AFAIK, the IDE adds them as "preset" includes.

I do not know the term, AFAIK. Is this an acronym or what?

And the phrase, "the IDE adds them as "preset" includes."; does this refer
to the precompiled Include files or is this something else??



Back to top
Helmut Giese
Guest





PostPosted: Tue Jul 26, 2005 11:03 pm    Post subject: Re: #include ?????? Reply with quote

Hi Wayne,
Quote:
This is the first situation that I have encountered where one is added
automatically for me. And pardon me but that came as a surprise, and as I
said, a bit Weird.

If the compiler is capable of determining which Include file is needed (and
has some feature to add it automatic for me), why do I have to add the
#Include for it to avoid an error message?
well, it's not quite like this. With VCL forms there is just this

convention: a file myform.cpp will #include a header file myform.h -
and if you deleted this line the IDE will add it back in. That's the
convention, and you're free to consider it a bug or a feature.

Of course, if you forget to #include, say math.h, the compiler will
bark at you.

Quote:
The question is not, "what are Include files for?", but how do I control the
feature that causes one to be added back after I delete it?
You don't - not for /this one/ header file.


Now, if I understood correctly what you wanted to achieve, I'd do
this:
Ok, I cannot fight the #include or this one file being added, but I
can control its content.
So you provide a (temporarily) empty header file and you will
immediately find out what the compiler is missing. Then you can add
back piece by piece - well, you get the idea.
HTH
Helmut Giese

Back to top
Jonathan Benedicto
Guest





PostPosted: Tue Jul 26, 2005 11:06 pm    Post subject: Re: #include ?????? Reply with quote

"Wayne" <DeWire (AT) Concentric (DOT) Net> wrote

Quote:
I do not know the term, AFAIK. Is this an acronym or what?

It is a acronym for As Far As I Know.

Quote:
And the phrase, "the IDE adds them as "preset" includes."; does this
refer to the precompiled Include files or is this something else??

I'm really not sure how the IDE determines what headers certain classes /
components need, but it seems to be independent of the compiler, because it
often inserts unnecessary includes, plus the IDE seems to do this
instantaneously, whereas a compiler would be slower.

Maybe the IDE stores info regarding the necessary includes somewhere, or it
might be stored in the package files, I really do not know.

Jonathan



Back to top
Ed Mulroy
Guest





PostPosted: Tue Jul 26, 2005 11:44 pm    Post subject: Re: #include ?????? Reply with quote

In general an include will not be added back into a source file.

The behavior you describe is characteristic of files that you have elected
to have the IDE manage, files which are at least partially written by the
IDE itself when you create a form or do other things with VCL objects.
Include statements are added just as class member response functions and
properties are handled. That is part of the RAD, Rapid Application
Development, system.

If you do not like it doing that then you need not use RAD. There is no
such behavior with normal C or C++ source files.

.. Ed

Quote:
Wayne wrote in message
news:42e6bf06 (AT) newsgroups (DOT) borland.com...
Thanks to all, Ed, Jonathan, and Jeff,

You have all been helpful and I appreciate.it.

My original problem has been resolved by other methods,
but I would still like to resolve the question,
"how do I control the feature that causes an #Include to be added back
after I delete it?".

Other then that, all the above leads me pursue a couple of new issues.
------------------------
Jeff wrote:
Wayne wrote:
The question is not, "what are Include files for?", but how do I control
the feature that causes one to be added back after I delete it?

Delete the #includes with some other editor and then compile the project
from the command line. I know this doesn't answer the question directly
but I think it kind of accomplishes what you want.

Thanks jeff, that seems like a good suggestion.

But as I said, I have resolved my original problem and I no longer need
you suggested work around.

Still, with respect to your suggestion, I might have a little trouble
selecting appropriate options for the compiler command.

Do you know if there is a good way to get the IDE to generate a command
without running the compiler?

------------------------
And Jonathan wrote:
In this case, AFAIK, it isn't the compiler that is adding the includes.
AFAIK, the IDE adds them as "preset" includes.

I do not know the term, AFAIK. Is this an acronym or what?

And the phrase, "the IDE adds them as "preset" includes."; does this refer
to the precompiled Include files or is this something else??



Back to top
Wayne
Guest





PostPosted: Wed Jul 27, 2005 5:51 am    Post subject: Re: #include ?????? Reply with quote

Helmut wrote:
Quote:
Now, if I understood correctly what you wanted to achieve, I'd do this:
Ok, I cannot fight the #include or this one file being added, but I
can control its content.
So you provide a (temporarily) empty header file and you will
immediately find out what the compiler is missing. Then you can add
back piece by piece - well, you get the idea.

Your understanding is exactly correct...
Thanks for your suggestion, its a good one. That would have solved my
original problem.

--------------------------
However, when you wrote...
Quote:
well, it's not quite like this. With VCL forms there is just this
convention: a file myform.cpp will #include a header file myform.h -
and if you deleted this line the IDE will add it back in. That's the
convention, and you're free to consider it a bug or a feature.

Of course, if you forget to #include, say math.h, the compiler will
bark at you.

I agree with the last line about the math.h include file, I have forgotten
to include a header file plenty of times and " the compiler will bark". I
can added 'em and I can delete 'em, this has never been a problem. But one
has never been added back after I deleted.

But I didn't feel that the other comment, "and if you deleted this line the
IDE will add it back in", was consistent with my previous experience.

So I tried an experiment...
I started the BCB and it created the default New Application.

Each Unit has two default Include file statements...
#include <vcl.h>
#include "Unit1.h"

I clicked Run and the BCB compiled and executed the default program with a
blank Form. No problem!

Then I deleted the Include file for the Unit1 by making it a comment, i.e.,
//#include "Unit1.h"

I clicked Run and the BCB compiler responded with a Declaration error. Big
problem!!!
E2141 Declaration syntax error Compiler error
No surprise there.

The surprise would have been that the BCB (IDE, Compiler or whatever) added
the include file back in! That did NOT happen!

I know that when I create a new unit, I can use the IDE - File|Include Unit
Hdr command to add an #include statement for an existing unit in the Code
editor.

But this characteristic of Include files being added is completely new to
me, and I have a good bit of experience with BCB. I have use it starting
with BCB Ver 1 and I have helped train several others learning to use it.

Then I deleted the VCL Include file for the Unit1 by making it a comment,
i.e.,
#include <vcl.h>

I clicked Run and the BCB compiled and executed the default program with a
blank Form. No problem! Big surprise!!, I would have thought that the
vcl.h file would have been needed, but it wasn't.

The vcl.h file is needed in the Project1.cpp unit. And when I delete it, it
did NOT come back.

So I added a button to Unit1 and put a statement Close(); in its OnClick
event. No problem, it compiled and executed just fine without the vcl.h
file.

No other Include files were added automatically nor were they needed.

So I added a Form; I had to manually add the include file of each Unit in
the other unit using the IDE - File|Include Unit Hdr command. All this was
expected and normal except the fact that the vcl.h file was not needed in
the Units

After adding several VCL Components, I was unable to find anything that
needed or added include files except non-VCL items like the math.h example.

Thanks again,
Wayne



Back to top
Wayne
Guest





PostPosted: Wed Jul 27, 2005 6:01 am    Post subject: Re: #include ?????? Reply with quote

Ed wrote:
Quote:
In general an include will not be added back into a source file.

Yes - I certainly agree.

--------------------------
Ed continued:
Quote:
The behavior you describe is characteristic of files that you have elected
to have the IDE manage, files which are at least partially written by the
IDE itself when you create a form or do other things with VCL objects.
Include statements are added just as class member response functions and
properties are handled. That is part of the RAD, Rapid Application
Development, system.

I don't feel that this is completely consistent with my previous experience.
Maybe you will fine my comments to Helmut interesting.

--------------------------
Then Ed continued:
Quote:
If you do not like it doing that then you need not use RAD. There is no
such behavior with normal C or C++ source files.

I have worked with C, C++ and BCB and I love what RAD does. I don't mind
adding statements nor do I mind deleting them. It would just be nice if
they stayed deleted when I delete them.
I was not complaining; I was just asking, is there a way to explain this
characteristic and can it be turned on and off.

By the way, maybe it was already obvious, but this problem occurred in a
Project that was not my own. I got it from the Internet. So I do not have
any knowledge of how or when this characteristic started.

Thanks,
Wayne



Back to top
Alisdair Meredith [TeamB]
Guest





PostPosted: Wed Jul 27, 2005 8:41 am    Post subject: Re: #include ?????? Reply with quote

Jonathan Benedicto wrote:

Quote:
I don't know. When I encountered this feature, I just gave up trying
to reduce the includes BCB puts in.

I now rely on this (in form headers) to get the minimal set of
#includes <g>

The logic is that every time a component on your form requires a
header, the IDE will automatically add it for you. As you add and
remove components over time, this list of headers grows and will
contain headers that are no longer needed.

Periodically I give my projects a 'spring clean' heading in to a
release cycle - I delete all headers apart from 'classes.hpp' and
re-make that file (ctrl-F9) BCB then adds back the minimum number of
extra headers it needs.

You should also delete all #pragma link lines added to your cpp file at
the same time, for the same effect. This can actually reduce the size
of your compiled application too.


After cleaning I put the headers into a predefined order according to
our internal conventions. This makes it easy to spot when a file has
been recently 'cleaned' so we don't need to worry about it again.


Note: BCB only adds the includes it detects are necessary for the
components on the form, NOT any that you add by hand for the parts of
the class you write yourself. Eg. if you use std::vector to store
data, BCB will NOT automatically insert #include <vector> for you.
Again, our code layout conventions move these headers to a commented
area after the 'managed' header area making them easy to identify. You
do NOT want to delete these headers when cleaning!!!

AlisdairM(TeamB)

Back to top
Jonathan Benedicto
Guest





PostPosted: Wed Jul 27, 2005 6:01 pm    Post subject: Re: #include ?????? Reply with quote

"Alisdair Meredith [TeamB]"
<alisdair.NO.SPAM.PLEASE.meredith (AT) uk (DOT) renaultf1.com> wrote

Quote:
I now rely on this (in form headers) to get the minimal set of
#includes <g

The logic is that every time a component on your form requires a
header, the IDE will automatically add it for you. As you add and
remove components over time, this list of headers grows and will
contain headers that are no longer needed.

Periodically I give my projects a 'spring clean' heading in to a
release cycle - I delete all headers apart from 'classes.hpp' and
re-make that file (ctrl-F9) BCB then adds back the minimum number of
extra headers it needs.

Do you mind if I don't agree with that "minimum". For example, I sometimes
use the Indy components, and if I just place the IdHTTP component on the
form, BCB adds these:

#include "IdBaseComponent.hpp"
#include "IdComponent.hpp"
#include "IdHTTP.hpp"
#include "IdTCPClient.hpp"
#include "IdTCPConnection.hpp"

If I open the IDHTTP.hpp file, all the other includes are in there, so BCB
should only have placed
#include "IdHTTP.hpp" in.

Quote:
You should also delete all #pragma link lines added to your cpp file at
the same time, for the same effect. This can actually reduce the size
of your compiled application too.

Thank you for these tips. I'll do this.

Quote:
Note: BCB only adds the includes it detects are necessary for the
components on the form, NOT any that you add by hand for the parts of
the class you write yourself. Eg. if you use std::vector to store
data, BCB will NOT automatically insert #include Again, our code layout conventions move these headers to a commented
area after the 'managed' header area making them easy to identify. You
do NOT want to delete these headers when cleaning!!!

Pity we don't have "smart" IDE's that automatically detect what we need and
include it. <g>

Jonathan



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.