我用vs2005编译wince5.0板子的程序,调用windows.h 出现下面错误,怎么回事

>D:\Program Files\Windows CE Tools\wce500\Unxx\include\ARMV4I\winnt.h(2976) : error C2061: syntax error : identifier 'PCONTEXT'
1>D:\Program Files\Windows CE Tools\wce500\Unxx\include\ARMV4I\winnt.h(2977) : error C2059: syntax error : '}'
1>D:\Program Files\Windows CE Tools\wce500\Unxx\include\ARMV4I\winbase.h(1405) : error C2061: syntax error : identifier 'LPCONTEXT'
1>D:\Program Files\Windows CE Tools\wce500\Unxx\include\ARMV4I\winbase.h(1405) : error C2059: syntax error : ';'
1>D:\Program Files\Windows CE Tools\wce500\Unxx\include\ARMV4I\winbase.h(2089) : error C2146: syntax error : missing ')' before identifier 'lpContext'
1>D:\Program Files\Windows CE Tools\wce500\Unxx\include\ARMV4I\winbase.h(2089) : error C2081: 'LPCONTEXT' : name in formal parameter list illegal
1>D:\Program Files\Windows CE Tools\wce500\Unxx\include\ARMV4I\winbase.h(2089) : error C2061: syntax error : identifier 'lpContext'
1>D:\Program Files\Windows CE Tools\wce500\Unxx\include\ARMV4I\winbase.h(2089) : error C2059: syntax error : ';'
1>D:\Program Files\Windows CE Tools\wce500\Unxx\include\ARMV4I\winbase.h(2090) : error C2059: syntax error : ')'
1>D:\Program Files\Windows CE Tools\wce500\Unxx\include\ARMV4I\winbase.h(2097) : error C2143: syntax error : missing ')' before '*'
1>D:\Program Files\Windows CE Tools\wce500\Unxx\include\ARMV4I\winbase.h(2097) : error C2143: syntax error : missing '{' before '*'
1>D:\Program Files\Windows CE Tools\wce500\Unxx\include\ARMV4I\winbase.h(2098) : error C2059: syntax error : ')'
1>.\src\ssbMgr.c(232) : error C2065: 'strcpy_instead_use_StringCbCopyA_or_StringCchCopyA' : undeclared identifier
1>.\src\ssbMgr.c(274) : error C2065: 'sprintf_instead_use_StringCbPrintfA_or_StringCchPrintfA' : undeclared identifier
1>.\src\ssbMgr.c(276) : error C2065: 'strcat_instead_use_StringCbCatA_or_StringCchCatA' : undeclared identifier
1>ROMPatchSettings.c
1>D:\Program Files\Windows CE Tools\wce500\Unxx\include\ARMV4I\winnt.h(2976) : error C2061: syntax error : identifier 'PCONTEXT'
1>D:\Program Files\Windows CE Tools\wce500\Unxx\include\ARMV4I\winnt.h(2977) : error C2059: syntax error : '}'
1>D:\Program Files\Windows CE Tools\wce500\Unxx\include\ARMV4I\winbase.h(1405) : error C2061: syntax error : identifier 'LPCONTEXT'

这个问题看着内容很多,其实可能问题要改动的很少,但是要找到地方却是很难的,这么多问题,什么少个逗号星号什么的这么多,一般是宏定义顺序不对,由此可能是头文件包含顺序不对,或者#if #else #endif 和#ifdef #ifndef这些开关的逻辑不对,当然如果你犯了括号不匹配的问题我就只能无语了,这个你只能一步步回溯了,如,你先看winnt.h,'PCONTEXT'在哪里,为什么没有定义,你这显示是在2976,应该是个结构体类型,那么是这个结构体类型没被定义,你再去看这个,是被什么宏开关控制了,再跟这个宏开关,等等,看到最后你会发现某个宏定义在一个文件里面,但是这个文件的位置在后面,导致某结构无法识别,所以你要把头文件提前,具体的只能你自己找了
给你个例子
a.h
#ifdef BBB
typedef struct a{
int x;
}STRCT_A;
#endif

b.h
#define BBB

c.c
#include "a.h"
#include "b.h"
#ifdef BBB
STRCT_A sa = {0};
#endif

这里c里面肯定编译失败,因为你先include a.h,然后发现没有定义BBB,所以没有STRCT_A这个结构,然后你又include b.h,所以在c里面有STRCT_A sa = {0};这行,然后就不认识STRCT_A,所以后面就有各种错了 ,解决的方法就是在c.c里include的顺序换一下就可以了追问

winnt.h 是微软给的标准头文件,里面确实有开关去控制,比如说#if defined (_ARM_),我没在其他地方发现这个宏的定义,难道是环境变量?该怎么去设置

追答

ARM是一种编译器,如果你是使用arm编译器编译的,那么这个宏就是定义了的,一般来说标准头文件不会有问题,出现这种问题一般是你自己include标准头文件的时候顺序不对或者有些需要include的文件没有添加进来,如果你自己的文件不多,你可以尝试看看哪些包括了系统头文件的

温馨提示:答案为网友推荐,仅供参考

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网