TWAIN协议编程twain.h中提示有错误,不知道怎样修改,希望大虾们指点

funrain 2010-10-31 02:18:51
主要两个错误:1。twain.h(104) : error C2146: syntax error : missing ';' before identifier 'TW_HANDLE'
2。twain.h(104) : fatal error C1004: unexpected end of file found。
原文是:#define _MSWIN_

#ifdef _MSWIN_
typedef HANDLE TW_HANDLE;//就是提示这里有错误
typedef LPVOID TW_MEMREF;

/* SDH - 05/05/95 - TWUNK */
/* For common code between 16 and 32 bits. */
#ifdef WIN32
#define TW_HUGE
#else /* WIN32 */
#define TW_HUGE huge
#endif /* WIN32 */
typedef BYTE TW_HUGE * HPBYTE;
typedef void TW_HUGE * HPVOID;
#endif /* _MSWIN_ */
...全文
200 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
nicolas16 2012-10-30
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 的回复:]
解决问题思路和过程:

查询MSDN中C2146的错误说明,如下:
syntax error : missing 'token' before identifier 'identifier'
The compiler expected the given token to appear before the given identifier.
Tips
This error is us……
[/Quote]高手,细致认真
lixing01 2010-10-31
  • 打赏
  • 举报
回复
HANDLE没有定义,有的机器行,有的编译器有问题,应该都是你的编译器或者创建工程类型时的一些配置引发的.
lixing01 2010-10-31
  • 打赏
  • 举报
回复
解决问题思路和过程:

查询MSDN中C2146的错误说明,如下:
syntax error : missing 'token' before identifier 'identifier'
The compiler expected the given token to appear before the given identifier.
Tips
This error is usually preceeded by error C2065. The most typical cause of this error is a typographical problem. For example:
void main(void)
{
intt x; //Syntax error: missing semicolon before 'x'
}

分析你的错误提示:error C2146: syntax error : missing ';' before identifier 'TW_HANDLE'
字面上看意思是在TW_HANDLE之前没有定义';',但MSDN提示这个错误往往是由"C2065",类型没有定义
MSDN说明:
Compiler Error C2065
'identifier' : undeclared identifier
The specified identifier was not declared.


由此分析,typedef准备指定类型别名,但被指定的类型并没有定义,即HANDLE没有定义.
所以:
#include <windows.h> //应该能解决你的问题,或者检查一下你默认使用预编译头文件<stdafx.h>不妥导致

至于你的第二个错误:fatal error C1004: unexpected end of file found,应该是由第一个错误连锁引发的
funrain 2010-10-31
  • 打赏
  • 举报
回复
另一台机子上又行了,但换成另一个编译器又有另外一个地方错误,不知道这是咋回事。
小驴 2010-10-31
  • 打赏
  • 举报
回复

typedef HANDLE TW_HANDLE;//就是提示这里有错误




你把这句删掉,再自己重新打一遍试试,我以前也遇到这种情况..

3,882

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 其它技术问题
社区管理员
  • 其它技术问题社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧