Author Topic: Any shortcuts for adding include directories to a project?  (Read 4576 times)

johnc

  • Guest
Any shortcuts for adding include directories to a project?
« on: June 25, 2006, 04:16:14 pm »
I'm setting up a very large C::B project with source and headers scattered through 100's of sub-directories. I love the ability to add files recursively - saves lots of work. But I haven't found anything similar for setting the include directories for MinGW compiler. I have to laboriously enter each one via the 'properties' dialog. Am I missing something?



As a general comment, it seems odd that a header file can be included in a C::B project, but the compiler can't find it unless you add the include path. Wouldn't it be nice if the include path was added whenever you add a header file?

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Any shortcuts for adding include directories to a project?
« Reply #1 on: June 25, 2006, 06:23:23 pm »
Quote
it seems odd that a header file can be included in a C::B project, but the compiler can't find it unless you add the include path. Wouldn't it be nice if the include path was added whenever you add a header file?
While that's true from a certain point of view, it has a problem. You don't necessarily want all headers to be present in all targets. However, the IDE has no way of knowing this. Furthermore, the order of inclusions may be vital, which again the IDE has no knowledge about.

So yes, you have a valid point, but this would need to be done a little more carefully than simply adding directories automatically.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

johnc

  • Guest
Re: Any shortcuts for adding include directories to a project?
« Reply #2 on: June 25, 2006, 07:35:10 pm »
The points you raise are only valid for special cases - multiple targets and complex situations where header inclusion order is important. Surely it would be easier to automatically add directories to the 'include' list as header files are added to a project, then go through and delete or edit the list after this initial phase. Given that C::B users are already used to building a project in two phases - add files, then add includes directories - my proposed modification would not be disruptive and would represent a real improvement. Do you agree?

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
Re: Any shortcuts for adding include directories to a project?
« Reply #3 on: June 25, 2006, 11:00:51 pm »
Sorry but I don't agree. I wouldn't like to see such automagic behavior by default from an IDE.

If you place headers in one place and sources in another, only one path needs to be added to the include list. The IDE shouldn't decide this for you. In most cases that's enough since every other header, in a subfolder, you need to include could just be included with its relative path (like #include <wx/wx.h>).

It sounds like trying to extend the "Explicitely add current compiling..." and "Explicitely add project's top-level..." options (which I've never had to use).

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Any shortcuts for adding include directories to a project?
« Reply #4 on: June 26, 2006, 12:18:10 am »
It sounds like trying to extend the "Explicitely add current compiling..." and "Explicitely add project's top-level..." options (which I've never had to use).
Exactly. I don't think that having too many automatic "smart" things is smart at all. Computers just aren't smart. Look at all these smart MS programs. They're so darn smart that you can't work with them.

The computer should do exactly what you tell it to do, not any random stuff or anything that you don't know about or have no control over. That is not good behaviour.

I would agree on having something like this as an option (it could even be encapsulated in a plugin, so people who want it can load it and people who dislike the idea aren't stuck with it). For example, it could allow you to select a menu and then could open a dialog having a checklist with all known directories that are not yet in the includes list. Thus, after adding all the directories, you could select the ones that you want as include paths, and hit OK.
However, you should explicitely have to ask for it, such a thing should never happen secretly behind the scenes.

And still, it is not that easy. You still have to specify which targets need which subset of includes, and you should be able to specify their order, too.

A good real life example for why this is important can be found inside the very Code::Blocks sources:
Code::Blocks uses the wxAUI docking library. This library consists of two files, manager.h and manager.cpp. As it happens, the Code::Blocks SDK has two files with the exact same name.
Now, what if you just blindly add all subdirectories in arbitrary order? You have a 50% chance of including the wrong file in either target.
This is really bad, including the correct file has to be deterministic, not stochastic.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."