Issue:
When I upgrade an exe project from VC7.1 to VC8, it says upgrade
succeed. But When I try to compile the project, it outputs a lot of errors.
../debug/msado15.tlh(1024) : error C2327: 'CDO::_ADO::Properties' : is not a type name, static, or enumerator
../debug/msado15.tlh(2086) : error C2327: 'CDO::Command15::Parameters' : is not a type name, static, or enumerator
../debug/msado15.tlh(2285) : error C2327: 'CDO::Connection15::Errors' : is not a type name, static, or enumerator
../debug/msado15.tlh(2525) : error C2327: 'CDO::Recordset15::Fields' : is not a type name, static, or enumerator
../debug/msado15.tlh(3124) : error C2327: 'CDO::_Record::Fields' : is not a type name, static, or enumerator
../debug/msado15.tli(109) : error C2065: '_result' : undeclared identifier
../debug/cdosys.tlh(628) : error C2327: 'CDO::IConfiguration::Fields' : is not a type name, static, or enumerator
../debug/cdosys.tlh(814) : error C2327: 'CDO::IBodyPart::Fields' : is not a type name, static, or enumerator
../debug/cdosys.tlh(1090) : error C2327: 'CDO::IMessage::Fields' : is not a type name, static, or enumerator
../debug/cdosys.tlh(1100) : error C2327: 'CDO::IMessage::Fields' : is not a type name, static, or enumerator
In my project, the import sentences are written like follows:
#include "stdafx.h"
#include "Resource.h"
#include "ProcessorThread.h"
#include <string>
#import "c:/program files/common files/system/ado/msado15.dll"
rename("ADODB","CDO") rename( "EOF", "adoEOF" )
#import <cdosys.dll>
Root Reason:
The msado15.tlh and cdosys.tlh are not generated correctly. When I compare the .tlh file generated by 2003 and 2005, I noticed the keyword “struct” is missed in some method definitions in the tlh file generated by 2005.
For example: in msado15.tlh
virtual HRESULT __stdcall get_Item (
/*[in]*/ VARIANT Index,
/*[out,retval]*/
struct Property * * ppvObject ) = 0; // this
struct is missed in the tlh generated under VS2005
virtual HRESULT __stdcall get_Item (
/*[in]*/ VARIANT Index,
/*[out,retval]*/
struct Error * * ppvObject ) = 0; // this
struct is missed in the tlh generated under VS2005
The generation of tlh files is affected by some codes in this project, which is compiled earlier than the import sentences.
Solution:
Move the import sentences to the very beginning of stdafx.h. Maybe move to other positions could also make things work. The only thing I did is to make the import sentences compiled earlier than other sentences, by moving their position.