warning C4003: not enough actual parameters for macro 'SubclassWindow'

今天包含了一个静态库出现warning C4003: not enough actual parameters for macro 'SubclassWindow'接下来是一大堆不可思议的错误。怎么SubclassWindow变成宏了?

经查WindowsX.h中定义了SubclassWindow宏,因此如果包含了WindowsX.h头文件,如果你再调用了CWnd::SubclassWindow那么就会出现这种错误。

解决方法:添加 #undef SubclassWindow

 

下面是http://blog.csdn.net/sirguan/article/details/1554298看到的相同问题,写的比较全面

 

  
今天修改工程,为了提高编译速度,将#inclue<dshow.h>放到了stdafx.h中,然后重新编译工程。结果有两个文件编译没通过,并且导致的编译错误近百个。
觉得奇怪,没有什么大的改动啊,难道是#include<dshow.h>搞的鬼?于是,将这条语句挪回原来的位置,重新编译,通过了。
到底怎么回事?
又把这条语句放入stdafx.h中,重新编译,仔细观察出错编译结果,第一个警告很让人迷惑, warning C4003: not enough actual parameters for macro 'SubclassWindow'
SubClassWindow什么时候成宏了啊,记得是一个函数啊?说不定是编译器的错误,不管了,往下看。下面的看了就头大了,什么BOOL重新定义了,什么RECT定义找不到啊,一大堆根本不可能的错误,难道编译器真的出问题了?
慢着,为什么说SubclassWindow是宏呢?如果编译器真的出问题了,工程中其他使用RECT的文件怎么会顺利编译呢?直觉告诉我,和这个SubclassWindow有关。于是看了另外一个文件的出错信息,第一行是一个相同的warning。搜了一下工程,只有这两个文件用到了subclasswindow,看来罪魁祸首已经找到了。
如何解决呢?
警告信息写着呢,SubclassWindow这个宏的参数不够,看来是有地方把它定义成宏了,那只要加入#undef SubclassWindow应该就可以了。试了一下,果真可以了。
那到底是什么地方重新定义了SubclassWindow呢?在本地是不好找了,上baidu搜了一下,相关资料不多,但刚好有朋友碰到过相同的问题,并且给出了详细的解释,下面那位朋友原文的转发。
原来在一个项目中写好的类,运行一直没有问题。这次为了版本升级,重新包含在新的项目中,编译始终报错:
 
warning C4003: not enough actual parameters for macro 'SubclassWindow'
 
pWnd->SubclassWindow(m_hWndHooked);
 
源码中这句话怎么也通不过,这子类化窗体哪里写错了?反复对比 2 个版本,没有任何差异阿 ...
 
又把类库从头到尾分析了一遍,足足花去 3 个小时! .... .... 从源码到编译环境设置,都没有什么差异阿 ...
 
实在想不通 .
 
最后还是在 MSDN 里找到这个报告:
 
BUG: C4003: Not Enough Parameters for SubclassWindow Macro
Article ID : 150076
Last Review : September 18, 2003
Revision : 3.0
This article was previously published under Q150076
 
 
SYMPTOMS
When compiling a Microsoft Foundation Class (MFC) application that uses the Windowsx.h header file and calls CWnd::SubclassWindow(), you may get the following error:
 
 
warning C4003: not enough actual parameters for macro 'SubclassWindow' error C2059: syntax error : ')'
 
 
CAUSE
The Windowsx.h file is a header that includes message cracker macros to help programmers write more portable Windows-based applications. The header file contains a preprocessor macro named SubclassWindow. The macro bears the same name as the CWnd::SubclassWindow() member function. The macro has two parameters; the member function has only one parameter. The preprocessor tries to expand the symbol SubclassWindow when it is found.
 
 
RESOLUTION
You can un-define the macro as follows:
 
#undef SubclassWindow      
 
因此,我的项目出错原因也很明显了,因为Dshow.h里面包含了windowsx.h。
总结
l         一定要注意编译器的异常警告信息
l         修改工程配置或者改变文件包含关系的时候,最好能保证每次或者每几次的改动都是可编译的,这样会更容易定位错误。

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值