现在的位置: 首页 > 综合 > 正文

TWAIN协议编程twain.h中提示有异常

2013年03月03日 ⁄ 综合 ⁄ 共 1585字 ⁄ 字号 评论关闭

转自:http://www.expopro.info/home.php?u=kU6eXtVnWgDtmdao5XUk7M4NnIFjYuNKcrOwuxtq%2FvCEYnwjGA%3D%3D&b=29


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

主要两个错误: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_ */


------解决方案--------------------------------------------------------

C/C++ code

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

------解决方案--------------------------------------------------------

解决问题思路和过程:

查询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,应该是由第一个错误连锁引发的

------解决方案--------------------------------------------------------
HANDLE没有定义,有的机器行,有的编译器有问题,应该都是你的编译器或者创建工程类型时的一些配置引发的.

抱歉!评论已关闭.