关于 not enough actual parameters for macro ...
From: http://blog.csdn.net/liyelun/article/details/5416253
今天修改工程,為了提高編譯速度,將#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???????? 修改工程配置或者改變文件包含關系的時候,最好能保證每次或者每幾次的改動都是可編譯的,這樣會更容易定位錯誤。
總結
以上是生活随笔為你收集整理的关于 not enough actual parameters for macro ...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 协作机器人关节模组总结
- 下一篇: **【ci框架】精通CodeIgnite