unsignend short* 转换为BSTR时候错误了
#ifndef String
typedef unsigned short *String;
#endif
_com_util::ConvertBSTRToString // 这里错误
BOOL CDictionary::LoadLibrary(String filename)
{
char *pFileName = _com_util::ConvertBSTRToString(filename); //error
FILE *fp;
if( (fp = fopen( pFileName, "rt" )) == NULL ) {
printf("Open dictionary file : %s failed.\n", pFileName);
delete pFileName;
return FALSE;
}
namespace _com_util {
// Convert BSTR to char *
//
char* __stdcall ConvertBSTRToString(BSTR pSrc) ;
}
也就是说,原作者的意图是:将 unsigned short* 转化为BSTR时候发生错了。
我们去类BSTR中看看有没有构造函数啊
class _bstr_t {
public:
// Constructors
//
_bstr_t() throw();
_bstr_t(const _bstr_t& s) throw();
_bstr_t(const char* s) ;
_bstr_t(const wchar_t* s) ;
_bstr_t(const _variant_t& var) ;
_bstr_t(BSTR bstr, bool fCopy) ;
// Destructor
//
~_bstr_t() throw();
// Extractors
//
operator const wchar_t*() const throw();
operator wchar_t*() const throw();
operator const char*() const ;
operator char*() const ;
// Low-level helper functions
//
BSTR copy(bool fCopy = true) const ;
unsigned int length() const throw();
// Binary string assign
//
void Assign(BSTR s) ;
// Get the physical BSTR
//
BSTR& GetBSTR() ;
BSTR* GetAddress() ;
// Attach to the internal BSTR w/o copying
//
void Attach(BSTR s) ;
// Detach the internal BSTR
//
BSTR Detach() throw();
private:
// Referenced counted wrapper
//
class Data_t {
public:
// Constructors
//
Data_t(const char* s) ;
Data_t(const wchar_t* s) ;
Data_t(BSTR bstr, bool fCopy) ;
Data_t(const _bstr_t& s1, const _bstr_t& s2) ;
// Reference counting routines
//
unsigned long AddRef() throw();
unsigned long Release() throw();
unsigned long RefCount() const throw();
// Extractors
//
operator const wchar_t*() const throw();
operator const char*() const ;
// Low-level helper functions
//
const wchar_t* GetWString() const throw();
wchar_t*& GetWString() throw();
const char* GetString() const ;
BSTR Copy() const ;
void Assign(BSTR s) ;
void Attach(BSTR s) throw();
unsigned int Length() const throw();
int Compare(const Data_t& str) const throw();
// Exception agnostic wrapper for new
//
void* operator new(size_t sz);
private:
BSTR m_wstr;
mutable char* m_str;
unsigned long m_RefCount;
// Never allow default construction
//
Data_t() throw();
// Never allow copy
//
Data_t(const Data_t& s) throw();
// Prevent deletes from outside. Release() must be used.
//
~Data_t() throw();
void _Free() throw();
};
private:
// Reference counted representation
//
Data_t* m_Data;
private:
// Low-level utilities
//
void _AddRef() throw();
void _Free() throw();
int _Compare(const _bstr_t& str) const throw();
};
//////////////////////////////////////////////////////////////////////////////
似乎没啊, 当时作者写书的时候,在vc6下写,现在 的编译器已经无法编译了