I get the following error(s) when compiling:
3>Time Elapsed 00:00:00.10
2>ClCompile:
2> Main.cpp
2> CWnd.cpp
2>c:\repo\~\clabel.hpp(11): error C2061: syntax error : identifier 'CWnd'
2>c:\repo\~\cbutton.hpp(11): error C2061: syntax error : identifier 'CWnd'
2>c:\repo\~\cmainwnd.hpp(9): error C2504: 'CWnd' : base class undefined
2> CMainWnd.cpp
2> CLabel.cpp
2> CException.cpp
2> CButton.cpp
2> Generating Code...
2>
2>Build FAILED.
My project looks like this (where each part includes the header file one level above)
DefaultHeader.hpp : (windows.h, includes CInterface.hpp, other header files)
-- CInterface.hpp : (includes DefaultHeader.hpp, CWnd.hpp, CLabel.hpp and CButton.hpp)
-- -- CWnd.hpp : (includes CInterface.hpp)
-- -- CLabel.hpp : (includes CInterface.hpp)
-- -- CButton.hpp : (includes CInterface.hpp)
Here is the definition of CWnd
#ifndef __CWnd_hpp__
#define __CWnd_hpp__
#pragma once
#include "CInterface.hpp"
class CWnd
{
...
};
#endif // __CWnd_hpp__
I am unsure why I get this error when trying to access CWnd, as CWnd (and all its members) are clearly defined.
The 3 lines the errors occur (snipped out, for reference):
CLabel ( CWnd* wndParent, INT iX, INT iY, INT iWidth, INT iHeight, LPCTSTR lpszCaption );
CButton ( CWnd* wndParent, INT iX, INT iY, INT iWidth, INT iHeight, LPCTSTR lpszCaption );
class CMainWnd : public CWnd
Strangest part is Itellisense sees no errors until I compile, then they appear and disappear about 2 seconds later.
Any help is appreciated.
Turns out the header file CInterface was locking up and not including CWnd.hpp in some files. I fixed this issue by having all files include the highest level include file DefaultHeader.hpp instead if their corresponding include files CLabel.hpp, CButton.hpp, etc.