我在OCX中调用msado15.dll模块,在StdAfx.h中调用如下;
#import "bin\msado15.dll" no_namespace rename("EOF","adoEOF")结果编译时系统报错如下:
d:\vc\myocx\debug\msado15.tlh(171) : error C2011: 'LockTypeEnum' : 'enum' type redefinition
d:\vc\myocx\debug\msado15.tlh(214) : error C2011: 'DataTypeEnum' : 'enum' type redefinition
d:\vc\myocx\debug\msado15.tlh(258) : error C2011: 'FieldAttributeEnum' : 'enum' type redefinition
d:\vc\myocx\debug\msado15.tlh(279) : error C2011: 'EditModeEnum' : 'enum' type redefinition
d:\vc\myocx\debug\msado15.tlh(287) : error C2011: 'RecordStatusEnum' : 'enum' type redefinition
d:\vc\myocx\debug\msado15.tlh(407) : warning C4146: unary minus operator applied to unsigned type, result still unsigned
d:\vc\myocx\debug\msado15.tlh(530) : error C2011: 'ParameterDirectionEnum' : 'enum' type redefinition
Error executing cl.exe.MyOCX.ocx - 6 error(s), 1 warning(s)可是我在程序中并没有找到这些enum类型在其他地方有定义。不知道这是出了什么问题?急切请教高手们。

解决方案 »

  1.   

    #import "bin\msado15.dll" no_namespace rename("EOF","adoEOF")这句能不能不要加在StdAfx.h里?
      

  2.   

    // stdafx.h : include file for standard system include files,
    //  or project specific include files that are used frequently, but
    //      are changed infrequently
    //#if !defined(AFX_STDAFX_H__424F0C54_75BC_4F56_BA1E_4E583AE24E5E__INCLUDED_)
    #define AFX_STDAFX_H__424F0C54_75BC_4F56_BA1E_4E583AE24E5E__INCLUDED_#if _MSC_VER > 1000
    #pragma once
    #endif // _MSC_VER > 1000#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers#include <afxwin.h>         // MFC core and standard components
    #include <afxext.h>         // MFC extensions#ifndef _AFX_NO_OLE_SUPPORT
    #include <afxole.h>         // MFC OLE classes
    #include <afxodlgs.h>       // MFC OLE dialog classes
    #include <afxdisp.h>        // MFC Automation classes
    #endif // _AFX_NO_OLE_SUPPORT
    #ifndef _AFX_NO_DB_SUPPORT
    #include <afxdb.h> // MFC ODBC database classes
    #endif // _AFX_NO_DB_SUPPORT#ifndef _AFX_NO_DAO_SUPPORT
    #include <afxdao.h> // MFC DAO database classes
    #endif // _AFX_NO_DAO_SUPPORT#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
    #ifndef _AFX_NO_AFXCMN_SUPPORT
    #include <afxcmn.h> // MFC support for Windows Common Controls
    #endif // _AFX_NO_AFXCMN_SUPPORT/*#import "c:\program files\common files\system\ado\msado15.dll"rename ("EOF", "adoEOF")
    rename_namespace("ado20");
    using  namespace ado20;*/
    /*#import "c:\Program Files\common Files\system\ado\msado15.dll" rename ("EOF","adoEOF") rename_namespace("ado20")
    using namespace ado20;*/
    #import   "C:\WINNT\system32\Msstdfmt.dll"   no_namespace   
    #pragma warning(disable:4146)
    #import "C:\Program Files\Common Files\System\ADO\msado15.dll" named_guids rename("EOF","adoEOF"), rename("BOF","adoBOF")
    #pragma warning(default:4146)
    using namespace ADODB; //{{AFX_INSERT_LOCATION}}
    // Microsoft Visual C++ will insert additional declarations immediately before the previous line.#endif // !defined(AFX_STDAFX_H__424F0C54_75BC_4F56_BA1E_4E583AE24E5E__INCLUDED_)
      

  3.   

    我重新检查了 stdafx.h ,发现问题出在#include <afxdao.h>// MFC DAO database classes把这句取消就可以了,加上这句就报错:
    d:\vc\myocx\debug\msado15.tlh(171) : error C2011: 'LockTypeEnum' : 'enum' type redefinition
    d:\vc\myocx\debug\msado15.tlh(214) : error C2011: 'DataTypeEnum' : 'enum' type redefinition
    d:\vc\myocx\debug\msado15.tlh(258) : error C2011: 'FieldAttributeEnum' : 'enum' type redefinition
    d:\vc\myocx\debug\msado15.tlh(279) : error C2011: 'EditModeEnum' : 'enum' type redefinition
    d:\vc\myocx\debug\msado15.tlh(287) : error C2011: 'RecordStatusEnum' : 'enum' type redefinition
    d:\vc\myocx\debug\msado15.tlh(407) : warning C4146: unary minus operator applied to unsigned type, result still unsigned
    d:\vc\myocx\debug\msado15.tlh(530) : error C2011: 'ParameterDirectionEnum' : 'enum' type redefinition
    Error executing cl.exe.MyOCX.ocx - 6 error(s), 1 warning(s)可能问题出在dao库与ADO库中有重复定义。谢谢楼上各位的答复。