Oh, it looks like now the pch files were put seperatedly by wx28 project(under .objs\include) and wx29 project(under .objs29\include).
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.
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.
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:
#ifndef USE_PCH
#include <wx/dialog.h>
#endif
- 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:
#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
}
Implementation:
#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);
}
...that's basically it (if I didn't forget something... ;-)).