User forums > Using Code::Blocks
Project build options / Search directories
bnilsson:
I always respond to valid arguments, thanks.
Just to clarify:
What exactly is the bad practice?
Is it to structure the different source/header files in subdirectories according to function? wxWidgets, CB and may others does this...??
Or is it to refer to each subdirectory with its own path in the search list?
MortenMacFly:
--- Quote from: bnilsson on July 09, 2007, 11:39:38 pm ---What exactly is the bad practice?
--- End quote ---
You should only add path's to include directories that are really required. Even such a complex framework as wx requires one (or two) includes. So settings up include path from a "root" including all sub-path's makes no sense in most cases. In fact it will lead in to trouble for sure some time in the future. Just one example scenario:
Imagine the following directory structure:
--- Code: ---MyProject
- include
- lib_a_v1
- lib_a_v2
- lib_b
--- End code ---
If you setup the include path's as required which maybe here:
1.) include
2.) include\lib_a_v2
3.) include\lib_b
You will never run into trouble, even though you have to setup 3 directories.
If you setup the path's recursively starting from "include" it will result in:
1.) include
2.) include\lib_a_v1
3.) include\lib_a_v2
4.) include\lib_b
Now imagine the changes from lib_a_v1 to lib_a_v2 were an additional member in a structure. You won't receive any compilation errors when the first "definition file" (header files that defines the struct) is found in lib_a_v1. This would be th case as the compiler would first find it there due to the order of the include command line switches (alphabetically) in this example case). Hence if you rely on sizeof(mystruct) for any reason you compile possibly buggy code.
So *you* should ensure you always setup the right directories yourself, even if these are many and not leave it up to any IDE. In addition I have never seen any project that requires more then let's say 10 include directories. So it shouldn't be too hard to setup those step-by-step. However - That's only my personal opinion.
With regards, Morten.
bnilsson:
Ok, i think I get the point.
What would you think of a compromize: Allow multiple selections in the Project build settings / Search directories / Add dialog?
It would make life a little simpler, without putting the project in the hands of an unsuspecting IDE.
MortenMacFly:
--- Quote from: bnilsson on July 10, 2007, 12:22:28 pm ---Allow multiple selections in the Project build settings / Search directories / Add dialog?
--- End quote ---
This would be an easy change: You need to change the construction of EditPathDlg in compileroptionsdlg.cpp and activate the boolean flag "allowMultiSel" in the dialog construction.
Thus for compiler/linker include dirs you need to change (starting at line 1312 in r4247):
--- Code: --- EditPathDlg dlg(this,
m_pProject ? m_pProject->GetBasePath() : _T(""),
m_pProject ? m_pProject->GetBasePath() : _T(""),
_("Add directory"));
--- End code ---
...into:
--- Code: --- EditPathDlg dlg(this,
m_pProject ? m_pProject->GetBasePath() : _T(""),
m_pProject ? m_pProject->GetBasePath() : _T(""),
_("Add directory"), _T(""), true, true);
--- End code ---
This is untested. You may want to try and (if it works properly) create a patch out of it and submit it to BerliOS.
With regards, Morten.
Edit: Of course you need to handle multiple path's then in the code that follows after this in the method. Look how it's done on other places.
Navigation
[0] Message Index
[*] Previous page
Go to full version