读书人

求解释vs跟vc中引入tlb文件的差别

发布时间: 2012-10-18 13:46:55 作者: rapoo

求解释vs和vc中引入tlb文件的差别
我这里有两个.tlb文件。

我在vc中用

C/C++ code
#import"xxx.tlb"


编译成功,


但是为什么在vs2008中使用
C/C++ code
#import"xxx.tlb"


就会出现一大推的问题


C/C++ code
1>d:\great_alarm\222222\222222\debug\cssappserver.tlh(52) : error C2146: 语法错误 : 缺少“;”(在标识符“NetNode”的前面)1>d:\great_alarm\222222\222222\debug\cssappserver.tlh(52) : error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int1>d:\great_alarm\222222\222222\debug\cssappserver.tlh(52) : error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int1>d:\great_alarm\222222\222222\debug\cssappserver.tlh(64) : error C2146: 语法错误 : 缺少“;”(在标识符“GetNetNode”的前面)1>d:\great_alarm\222222\222222\debug\cssappserver.tlh(64) : error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int1>d:\great_alarm\222222\222222\debug\cssappserver.tlh(65) : error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int1>d:\great_alarm\222222\222222\debug\cssappserver.tlh(65) : warning C4183: “GetNetNode”: 缺少返回类型;假定为返回“int”的成员函数1>d:\great_alarm\222222\222222\debug\cssappserver.tlh(67) : error C2146: 语法错误 : 缺少“;”(在标识符“NetNodeByName”的前面)1>d:\great_alarm\222222\222222\debug\cssappserver.tlh(67) : error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int1>d:\great_alarm\222222\222222\debug\cssappserver.tlh(68) : error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int1>d:\great_alarm\222222\222222\debug\cssappserver.tlh(68) : warning C4183: “NetNodeByName”: 缺少返回类型;假定为返回“int”的成员函数1>d:\great_alarm\222222\222222\debug\cssappserver.tli(14) : error C2143: 语法错误 : 缺少“;”(在“CSSAppServer::IServer::GetNetNode”的前面)1>d:\great_alarm\222222\222222\debug\cssappserver.tli(14) : error C2433: “INetNodePtr”: 不允许在数据声明中使用“inline”1>d:\great_alarm\222222\222222\debug\cssappserver.tli(14) : error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int1>d:\great_alarm\222222\222222\debug\cssappserver.tli(14) : error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int1>d:\great_alarm\222222\222222\debug\cssappserver.tli(18) : error C2064: 项不会计算为接受 2 个参数的函数1>d:\great_alarm\222222\222222\debug\cssappserver.tli(28) : error C2143: 语法错误 : 缺少“;”(在“CSSAppServer::IServer::NetNodeByName”的前面)1>d:\great_alarm\222222\222222\debug\cssappserver.tli(28) : error C2433: “INetNodePtr”: 不允许在数据声明中使用“inline”1>d:\great_alarm\222222\222222\debug\cssappserver.tli(28) : error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int1>d:\great_alarm\222222\222222\debug\cssappserver.tli(28) : error C2086: “int CSSAppServer::INetNodePtr”: 重定义1>        d:\great_alarm\222222\222222\debug\cssappserver.tli(14) : 参见“CSSAppServer::INetNodePtr”的声明1>d:\great_alarm\222222\222222\debug\cssappserver.tli(28) : error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int1>d:\great_alarm\222222\222222\debug\cssappserver.tli(32) : error C2064: 项不会计算为接受 2 个参数的函数



注:
环境是win7 32位
编译器: vs2008,vc++ 6.0
语言:c++


怎么才能在vs中成功引入tlb文件

[解决办法]
The compiler provides the full path to any type library dependency required by the type library it is currently processing. The path is written, in the form of comments, into the type library header (.TLH) that the compiler generates for each processed type library.

If a type library includes references to types defined in other type libraries, then the .TLH file will include comments of the following sort:

Copy Code
//
// Cross-referenced type libraries:
//
// #import "c:\path\typelib0.tlb"
//


The actual filename in the #import comment is the full path of the cross-referenced type library, as stored in the registry. If you encounter errors that are due to missing type definitions, check the comments at the head of the .TLH to see which dependent type libraries may need to be imported first. Likely errors are syntax errors (for example, C2143, C2146, C2321), C2501 (missing decl-specifiers), or C2433 ('inline' not permitted on data declaration) while compiling the .TLI file.



You must determine which of the dependency comments are not otherwise provided for by system headers and then provide an #import directive at some point before the #import directive of the dependent type library to resolve the errors.

For more information, see the Knowledge Base article "#import Wrapper Methods May Cause Access Violation" (Q242527) or "Compiler Errors When You Use #import with XML" (Q269194). You can find Knowledge Base articles on the MSDN Library media or at http://support.microsoft.com/support/.


[解决办法]
可以需要先包含某些头文件,名字空间啥的。都检查下。

读书人网 >C++

热点推荐