我新建了一个MFC静态链接库,然后在stdafx.h头文件中加入
#import "c:\program files\common files\system\ado\msado15.dll"\
no_namespace \
rename("EOF","adoEOF")
编译出现错误如下:e:\实验\sll\release\msado15.tlh(171) : error C2011: 'LockTypeEnum' : 'enum' type redefinition
e:\实验\sll\release\msado15.tlh(214) : error C2011: 'DataTypeEnum' : 'enum' type redefinition
e:\实验\sll\release\msado15.tlh(258) : error C2011: 'FieldAttributeEnum' : 'enum' type redefinition
e:\实验\sll\release\msado15.tlh(279) : error C2011: 'EditModeEnum' : 'enum' type redefinition
e:\实验\sll\release\msado15.tlh(287) : error C2011: 'RecordStatusEnum' : 'enum' type redefinition
e:\实验\sll\release\msado15.tlh(407) : warning C4146: unary minus operator applied to unsigned type, result still unsigned
e:\实验\sll\release\msado15.tlh(531) : error C2011: 'ParameterDirectionEnum' : 'enum' type redefinition
执行 cl.exe 时出错.
这是为什么??

解决方案 »

  1.   

    重定义啊
    肯定是你的com和本程序中有重定义那些ENUM吧
      

  2.   

    奇怪,居然是那个错而不是 illagle escape sequence xxxx#import "c:\\program files\\common files\\system\\ado\\msado15.dll" \
    no_namespace \
    rename("EOF","adoEOF") 
    注意前面两行, 行末的\之后不能有空格
      

  3.   

    在你的stdafx.h文件中,还#include   其它数据库接口头文件,比如afxdb.h等。去掉就可以了。奇怪的是你这样写
    #import "c:\program files\common files\system\ado\msado15.dll"\ 
    居然是那个错而不是 illagle escape sequence xxxx #import "c:\\program files\\common files\\system\\ado\\msado15.dll" \ 
      

  4.   

    第一种方法是去掉#include <afxdao.h>// MFC ODBC database classes或#include <afxdb.h>// MFC DAO database classes
    第二种方法是  #import "d:\Program Files\Common Files\SYSTEM\ADO\msado15.dll" \
            no_namespace \
            rename ("EOF", "adoEOF") \
            rename ("LockTypeEnum", "adoLockTypeEnum") \
            rename ("DataTypeEnum", "adoDataTypeEnum") \
            rename ("FieldAttributeEnum", "adoFieldAttributeEnum") \
            rename ("EditModeEnum", "adoEditModeEnum") \
            rename ("RecordStatusEnum", "adoRecordStatusEnum") \
            rename ("ParameterDirectionEnum", "adoParameterDirectionEnum")
    在一种是引起#include <adoint.h>
    我今天也遇到了这个问题,试了好几种方法,采用了最后一种方法解决了,但不太清楚原因。希望高手指教
      

  5.   

    我的加入#import....后出现如下错,不知道是怎么回事儿:--------------------Configuration: CharToPinyin - Win32 Debug--------------------
    Compiling...
    StdAfx.cpp
    e:\2study\myprojects\chartopinyin\debug\msado15.tlh(407) : warning C4146: unary minus operator applied to unsigned type, result still unsigned
    d:\program files\microsoft visual studio\vc98\mfc\include\afxv_w32.h(14) : fatal error C1189: #error :  WINDOWS.H already included.  MFC apps must not #include <windows.h>
    执行 cl.exe 时出错.
    Creating browse info file...
    BSCMAKE: error BK1506 : cannot open file '.\Debug\StdAfx.sbr': No such file or directory
    执行 bscmake.exe 时出错.CharToPinyin.exe - 1 error(s), 0 warning(s)