Developer forums (C::B DEVELOPMENT STRICTLY!) > Development

Error building codeblocks 7860

<< < (5/7) > >>

MortenMacFly:

--- Quote from: ollydbg on February 29, 2012, 08:24:14 am ---Oh, it looks like now the pch files were put seperatedly by wx28 project(under .objs\include) and wx29 project(under .objs29\include).

--- End quote ---
True, I did that because otherwise they conflict. But thats another interesting issue: You guys might have an old PCH file which is used first due to the include order... So it might not work because of this.


--- Quote from: killerbot on February 29, 2012, 07:14:06 am ---we should be honest after all those years and say we just don't know how to do it, or we just keep on failing to do it right.

--- End quote ---
Well, we know how. And after all, the NON-PCH compilation (I mean with NOPCH switch, that's different from simply disabling PCH!) will be helpful to detect missing includes. Keep in mind that no matter what we do - wx will do and use PCH unless we declare NOPCH at the compile time. So even if we disable our PCH, the patches won't stop unless we do it properly in the first place.

The rules are plain simple:
PCH file:
- include all rarely changing header files
- do the PCH macro vodoo (we have that already)
Header:
- If you access or define an object, include the header
- If you use pointers/references, use forward decl
- Put headers you need to include into such a section if they are part of your PCH file:

--- Code: ---#ifndef USE_PCH
  #include <wx/dialog.h>
#endif

--- End code ---
- Include headers you need to include that are not part of your PCH file as normal
Implementation:
- include the PCH file first
- same thing for headers needed as in the header file.

I do it that way in my own projects and i works flawlessly for ages! Of course, whenever I change code and use new classes, I need to check the above rules.

But (nevermind) if we decide to get rid of this because these rules are too hard - go ahead.

Here comes a simple small class:
Header:

--- Code: ---#ifndef USE_PCH
  #include <wx/dialog.h> // is in wx_pch.h!
#endif

#include <wx/busyinfo.h> // NOT in wx_pch.h and used as object

class MyClass; // forward decsl due to pointer usage

class MyDlg: public wxDialog
{
  MyDlg() { ; };
  void Func(MyClass* c); // used as pointer
  wxBusyInfo bi; // used as object
}

--- End code ---
Implementation:

--- Code: ---#include <wx_pch.h> // our PCH file, may include the WX PCH file (if needed)

#include "MyDlg.h"

#ifndef USE_PCH
  #include "MyClass.h" // is in wx_pch.h, but now used as object / accessed
#endif

#include "MyOhterClass.h" // NOT in wx_pch.h and used as object

void MyDlg::Func(MyClass* c)
{
  MyOtherClass moc;
  c->DoSomething(moc);
}

--- End code ---

...that's basically it (if I didn't forget something... ;-)).

Jenna:
I don't think not doing things, because we did not do it correctly in some places is the way we should go.
Otherwise we should stop developping software, because there will always be errors.

We should find issues and remove them, nad we should keep the possibility to do it in another way ( like NOPCH does).

What I can say, is that without pch's it's much slower (no exact measurements) here on my laptop with Core2Duo, 2x2GHz and 3.3 GB usable Ram.
Another option to speed up things is the use of ccache (what I do here).

One thing I will change in the near futire,  is the place where the pch's are created by the utomake system.
At the momenbt they are created in the headers directory, even if C::B is created from a special build-folder.
This wil conflict, if the same sources are used for wx2.8 and wx2.9 or for automake and build with C::B !

This might need some changes to the include-directories used in the Makefile.am's .
I will do it as soon as possible.

ollydbg:
1, I copy morten's sample code in a section in wiki: 6 Header file include and Precompiled header rule

2, I like PCH, because it compiles much faster. So, please don't remove this feature in C::B. :)

PS: It looks like we have two big PCH files, both of them is about 100M( gcc 4.6, windowsXP), can we use only one? The most different is that they have some different #define macros.

oBFusCATed:
What happens if we just use the pch provided by wxwidgets or use a pch with all the external things in it?
How do I test the speed difference.

killerbot:
include rules. this reminds on something I wrote 3-4 years ago, but I forgot to publish. At that time Yiannis had prove read it.

It is still in the scratch pad section, have a look here : http://forums.codeblocks.org/index.php/topic,3321.0.html

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version