I'm moving a load of old code over to our new frame work, one section of this old code uses some MFC classes.
When trying to compile the class I am getting the error(s):
error C2504: 'CObject' : base class undefined
error C3861: 'VERIFY': identifier not found
error C3861: 'ASSERT': identifier not found
....
In my solution: properties -> General I have Use MFC in shared dll (I've also tried statically linking) General -> Charater set: Use Multi-Byte Character Set C/C++-> Precompiled headers -> Use
C/C++->Advanced Show includes YES
I'm including stdafx.h first on all files. I have afx.h and afxwin.h in stdafx.h (I've tried different orders and only including afxwin.h)
my stdafx.h
#pragma once
#include <afx.h>
#include <afxwin.h> // MFC core and standard components
#include "targetver.h"
#include <stdio.h>
#include <tchar.h>
The header file of the problem class
// blocksock.h
#include "stdafx.h"
#include <atlstr.h>
#include "winsock.h"
#include <string>
the includes of the .cpp of class
#include "stdafx.h"
#include "blocksock.h"
The first header to be shown to be included is:
\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\include\atlstr.h
The last include to be shown tobe included is:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\share.h
When I look at the command line I can see that it has the correct path to afx.h
I'm using VS2010.
What the hell is going on!!! It can see the MFC file but does not seem to recognize the class that is define within.
Note: I just tried swapping to
General -> Charater set: Use Unicode Character Set
as I noticed a comment in afx.h about being based on wchar_t
and instead of the above error gotloads of errorsabout MFC include files like this.
1> Note: including file: C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\include\atlalloc.h
1>c:\program files (x86)\microsoft visual studio 10.0\vc\atlmfc\include\atlconv.h(776): error C2440: 'return' : cannot convert from 'LPCTSTR' to 'LPCOLESTR'
LPCTSTRandLPCOLESTRuse different base types (wchar_tvs.unsigned short). This not a problem, unlesswchar_tis treated as a built-in type (Compiler option /Zc:wchar_t (wchar_t Is Native Type)). Changing this setting to "No" should fix that final error. - IInspectable