今天在将ADO类导出成DLL时碰到一个让人纠结的问题,本来不导出DLL时用的好好的,导出DLL时出现了问题了,查网发现还是有人碰到相同的问题的。
1>f:/c++ pro/iocptser/debug/msado15.tlh(228) : error C2011: “LockTypeEnum”: “enum”类型重定义
1> c:/program files/microsoft sdks/windows/v6.0a/include/dbdaoint.h(109) : 参见“LockTypeEnum”的声明
1>f:/c++ pro/iocptser/debug/msado15.tlh(276) : error C2011: “DataTypeEnum”: “enum”类型重定义
1> c:/program files/microsoft sdks/windows/v6.0a/include/dbdaoint.h(138) : 参见“DataTypeEnum”的声明
1>f:/c++ pro/iocptser/debug/msado15.tlh(321) : error C2011: “FieldAttributeEnum”: “enum”类型重定义
1> c:/program files/microsoft sdks/windows/v6.0a/include/dbdaoint.h(127) : 参见“FieldAttributeEnum”的声明
1>f:/c++ pro/iocptser/debug/msado15.tlh(343) : error C2011: “EditModeEnum”: “enum”类型重定义
1> c:/program files/microsoft sdks/windows/v6.0a/include/dbdaoint.h(83) : 参见“EditModeEnum”的声明
1>f:/c++ pro/iocptser/debug/msado15.tlh(352) : error C2011: “RecordStatusEnum”: “enum”类型重定义
解决方法:
#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;
#pragma warning指令含义为:
该指令允许有选择性的修改编译器的警告消息的行为
default:重置编译器的警告行为到默认状态
disable:禁止指定的警告信息
#pragma warning(disable:4146) // 不显示4146号警告信息
在vc中使用ADO的时候也会得到不必要的警告信息,这个时候我们可以通过
#pragma warning(disable:4146)来消除该类型的警告信息
正常情况下,c/c++中的标示符应该小于256字节,如果大于等于这个长度,那么vc就会给出警告。
#pragma warning(disable: 4786)这个命令就是用于关闭该警告的。