tempad
Readygo技术搜索引擎 >>项目管理 >> 一个有关没有定义的编译问题,请各位大虾看看

一个有关没有定义的编译问题,请各位大虾看看

Readygo技术搜索引擎 网络搜索 efish 2008-1-17 4:58:35

一个有关没有定义的编译问题,请各位大虾看看

楼主zhou80bin(彬彬)2002-11-07 12:22:13 在 VC/MFC / 基础类 提问

问题是这样的  
  我在  
  class   CMainFrame   :   public   CFrameWnd  
  {  
  ......  
  //中定义了一个函数  
  public:  
  bool   DoRegisterDeviceInterface(GUID       InterfaceClassGuid,HDEVNOTIFY   *hDevNotify);  
   
  //这个函数在msdn有,实际是RegisterDeviceNotification的一个例子  
  //其中的两个参数,我又分别定义成了,类的私有成员  
   
  private:  
  GUID   InterfaceClassGuid;  
                    HDEVNOTIFY   *hDevNotify;  
  //在理它们的定义已经包含在windows.h中,包括RegisterDeviceNotification  
  //但是编译的时候,却说  
   
  error   C2061:   syntax   error   :   identifier   "HDEVNOTIFY"  
  error   C2065:   "hDevNotify"   :   undeclared   identifier  
  error   C2065:   "RegisterDeviceNotification"   :   undeclared   identifier  
  等一系列错误  
   
  应该如何解决呢?这是什么原因造成的??谢谢了  
  问题点数:50、回复次数:14Top

1 楼YP2002CN(老婆我不敢了,老婆我愛你)回复于 2002-11-07 12:39:34 得分 0

#include   "Winuser.h"Top

2 楼zhou80bin(彬彬)回复于 2002-11-07 12:47:32 得分 0

不是在#include   "Windows.h"中已经包含了Winuser.h"了吗?  
  Top

3 楼my_mtx(水木)回复于 2002-11-07 14:03:01 得分 50

这与你的操作系统有关,你可以看看Winuser.h的2643行如下  
  #if(WINVER   >=   0x0500)  
  typedef     PVOID                       HDEVNOTIFY;  
  typedef     HDEVNOTIFY           *PHDEVNOTIFY;  
   
  #define   DEVICE_NOTIFY_WINDOW_HANDLE           0x00000000  
   
  WINUSERAPI  
  HDEVNOTIFY  
  WINAPI  
  RegisterDeviceNotificationA(  
          IN   HANDLE   hRecipient,  
          IN   LPVOID   NotificationFilter,  
          IN   DWORD   Flags  
          );  
  WINUSERAPI  
  HDEVNOTIFY  
  WINAPI  
  RegisterDeviceNotificationW(  
          IN   HANDLE   hRecipient,  
          IN   LPVOID   NotificationFilter,  
          IN   DWORD   Flags  
          );  
  #ifdef   UNICODE  
  #define   RegisterDeviceNotification     RegisterDeviceNotificationW  
  #else  
  #define   RegisterDeviceNotification     RegisterDeviceNotificationA  
  #endif   //   !UNICODE  
   
  WINUSERAPI  
  BOOL  
  WINAPI  
  UnregisterDeviceNotification(  
          IN   HDEVNOTIFY   Handle  
          );  
  #endif   /*   WINVER   >=   0x0500   */  
  Top

4 楼YP2002CN(老婆我不敢了,老婆我愛你)回复于 2002-11-07 14:09:26 得分 0

typedef     PVOID                       HDEVNOTIFY;  
  typedef     HDEVNOTIFY           *PHDEVNOTIFY;  
  //在這個之前加入上面的..估計是個  
  class   CMainFrame   :   public   CFrameWnd  
  {  
  Top

5 楼YP2002CN(老婆我不敢了,老婆我愛你)回复于 2002-11-07 14:10:04 得分 0

#if(WINVER   >=   0x0500)   就是這個其作用Top

6 楼my_mtx(水木)回复于 2002-11-07 14:11:09 得分 0

请注意#if(WINVER   >=   0x0500)此处,而在windows.h有如下定义  
  #ifndef   WINVER  
  #define   WINVER   0x0400  
  #else  
  #if   defined(_WIN32_WINNT)   &&   (WINVER   <   0x0400)   &&   (_WIN32_WINNT   >   0x0400)  
  #error   WINVER   setting   conflicts   with   _WIN32_WINNT   setting  
  #endif  
  即你未定义WINVER,则系统定义为0x0400  
  解:  
  在StdAfx.h添加  
  #define   WINVER   0x0500  
   
   
  如  
  #if   _MSC_VER   >   1000  
  #pragma   once  
  #endif   //   _MSC_VER   >   1000  
   
  #define   VC_EXTRALEAN //   Exclude   rarely-used   stuff   from   Windows   headers  
  #define   WINVER   0x0500  
  即可  
  Top

7 楼ruihuahan(飞不起来的笨鸟)回复于 2002-11-07 14:30:43 得分 0

upTop

8 楼zhou80bin(彬彬)回复于 2002-11-07 14:56:06 得分 0

Windows   headers  
  这句话加在Windows   headers是什么意思  
  Top

9 楼my_mtx(水木)回复于 2002-11-07 14:59:42 得分 0

是上面注释,你只要在前面加上#define   WINVER   0x0500  
  就行Top

10 楼zhou80bin(彬彬)回复于 2002-11-07 15:13:00 得分 0

我现在是在Win2000   pro下用VC  
  造成版本的原因是不是,我没装VS6的补丁??Top

11 楼zhou80bin(彬彬)回复于 2002-11-07 15:18:06 得分 0

编译通过,不过它的编译信息可以看看,这是编译的信息:  
   
   
   
  NOTE:   WINVER   has   been   defined   as   0x0500   or   greater   which   enables  
  Windows   NT   5.0   and   Windows   98   features.   When   these   headers   were   released,  
  Windows   NT   5.0   beta   1   and   Windows   98   beta   2.1   were   the   current   versions.  
  For   this   release   when   WINVER   is   defined   as   0x0500   or   greater,   you   can   only  
  build   beta   or   test   applications.     To   build   a   retail   application,  
  set   WINVER   to   0x0400   or   visit   http://www.microsoft.com/msdn/sdk  
  to   see   if   retail   Windows   NT   5.0   or   Windows   98   headers   are   available.  
  See   the   SDK   release   notes   for   more   information.  
  Compiling...  
  MainFrm.cpp  
  test2.cpp  
  test2Doc.cpp  
  test2View.cpp  
  Generating   Code...  
  Linking...  
   
  //下面这句话是什么意思啊??  
  LINK   :   LNK4073:   cannot   create   map   for   .ILK   file;   linking   nonincrementally  
  Top

12 楼my_mtx(水木)回复于 2002-11-07 15:21:48 得分 0

不是你可以在vc代码中看到如果你没有定义winver,系统会默认为0x0400  
  在看他的提示  
  #if(WINVER   >=   0x0500)  
  #pragma   message   ("")  
  #pragma   message   ("NOTE:   WINVER   has   been   defined   as   0x0500   or   greater   which   enables")  
  #pragma   message   ("Windows   NT   5.0   and   Windows   98   features.   When   these   headers   were   released,")  
  #pragma   message   ("Windows   NT   5.0   beta   1   and   Windows   98   beta   2.1   were   the   current   versions.")  
  #pragma   message   ("")  
  #pragma   message   ("For   this   release   when   WINVER   is   defined   as   0x0500   or   greater,   you   can   only")  
  #pragma   message   ("build   beta   or   test   applications.     To   build   a   retail   application,")  
  #pragma   message   ("set   WINVER   to   0x0400   or   visit   http://www.microsoft.com/msdn/sdk")  
  #pragma   message   ("to   see   if   retail   Windows   NT   5.0   or   Windows   98   headers   are   available.")  
  #pragma   message   ("")  
  #pragma   message   ("See   the   SDK   release   notes   for   more   information.")  
  #pragma   message   ("")  
  #endif  
  这说明一切Top

13 楼my_mtx(水木)回复于 2002-11-07 15:25:14 得分 0

是不是你的硬盘不足  
  rebuild   allTop

14 楼zhou80bin(彬彬)回复于 2002-11-07 15:33:07 得分 0

#pragma   message   ("For   this   release   when   WINVER   is   defined   as   0x0500   or   greater,   you   can   only")  
  #pragma   message   ("build   beta   or   test   applications.     To   build   a   retail   application,")  
  这段话是来吓唬人的吧??!!Top

责任编辑: efish 参与评论 查找更多:
相关文章
帮帮我吧!!!如何把字符串转化成实际对应的数值!… 帮帮我吧!!!如何把字符串转化成实际对应的数值!!类似eval(javascript)函数。
请问大家用的delphi6的汉化文件好吗? 请问大家用的delphi6的汉化文件好吗?
为什么论坛的搜索功能始终不能用? 为什么论坛的搜索功能始终不能用?
发现一本巨好的书 发现一本巨好的书
大家帮忙出三道C#的面试题 大家帮忙出三道C#的面试题
紧急求救!如何根据文本框名对jsp页面赋值??? 紧急求救!如何根据文本框名对jsp页面赋值???
一个棘手的问题,高分求助!!分数增加中....... 一个棘手的问题,高分求助!!分数增加中.......
MFC做界面怎么如此弱呀 MFC做界面怎么如此弱呀
谁有activebar2.0的破解码*********在线等候马上给分… 谁有activebar2.0的破解码*********在线等候马上给分****
哈哈哈。。。。。。。。。。终于同女友分手了! 哈哈哈。。。。。。。。。。终于同女友分手了!
2秒记住本站域名

玩过泡泡龙吗?Readygo?Go! 再加上.Com.Cn的后缀,那就是大名小顶的readygo.com.cn

分类导航
Readygo技术搜索引擎