Ok I've been coding in C++ for a long time. My project is getting rather large and not-withstanding the MSVC crash every 50 builds it is going rather well.
However the include stuff is a gigantic mess. So I went to edit some of it and now I have well over 1250 errors and no way to fix any of it.
In a C++ program correct me if I'm wrong but all headers needed for the CPP file should be in the respective header.
But in MFC the frieking includes are in the damned CPP file? Why?
And now I have a dialog (CLayersDlg.h) that needs to include CMainFrm.h, but the CMainFrm.h must also include CLayersDlg.h.
But when I do this, the stupid compiler tells me that basically this is undefined:
The solution in C++ is to use a #ifndef #define #endif block. This will prevent multiple includes but will solve the issue when you have a cyclical include. For some reason MFC is not doing this. Even though it defines some god awful #if (!defined AFX_SOME_BIG_NUMBER_BLAH_BLAH_BLAH) it is still using the same principle.
So why does this not work?
#if _MSC_VER > 1000
#endif // _MSC_VER > 1000
#include "LayersDlg.h" //Active layers dialog
//#include "MapProject.h" //Project->New response dialog
//#include "Tiles.h" //Tile tool dialog(s)
//#include "CResourceFile.h" //Resource file class
//#include "TileManager.h" //Tile manager class
class CMainFrame : public CFrameWnd
protected: // create from serialization only
//friend class CZeldaEditorDoc;
//Active layers dialog
And for one thing to compile LayersDlg.cpp and flag an error in MainFrm.h is just friggin stupid. MainFrm.h was included long before this and worked just fine.
D:\VC6Projects\ZeldaEditor2\MainFrm.h(57) : error C2146: syntax error : missing ';' before identifier 'dlgLayers'
D:\VC6Projects\ZeldaEditor2\MainFrm.h(57) : error C2501: 'LayersDlg' : missing storage-class or type specifiers
D:\VC6Projects\ZeldaEditor2\MainFrm.h(57) : error C2501: 'dlgLayers' : missing storage-class or type specifiers
What the heck is going on and how can I fix this include hell?
I need the CMainFrame class quite often for my dialogs so I need to include it so I can do this:
CMainFrame *ptrFrame=(CMainFrame *)AfxGetMainWnd();
I don't want a pointer to the actual MFC class, but I want a pointer to my derived class which is why I need to include CMainFrm.h
All this is really making me...um...mad.
And since my project is over 4K lines......I'm really mad now that I tried to add one thing and the whole program came crashing to its knees. Same issue. Included a header file so I could use it's class data type in a class header file and it said the damned thing was undefined. Unbelievable. I know what it is doing but I don't know why. It is saying that it is undefined because even though I put #include<some_header>, some_header has already been included and so it doesn't include it. But if some_header has already been defined then some_header inside of <some_header.h> should also be already defined. So doing this should work:
This should work. But this is exactly what I'm doing with LayersDlg and it is not working.