Listen to what the compiler is saying...
-
We can all have one of those days, this must have been one of them! Code:
DISP_FUNCTION(CPingerSink, "OnPingEvent", OnPingEvent, VT_EMPTY, VTS_UI4, VTS_BSTR)
Compiler: warning C4002: too many actual parameters for macro 'DISP_FUNCTION' A few cross words and pointing at other lines of code saying "Look, those have more parameters! What is wrong with you?". And also after a hour or so of wondering what day it was and whether I should have stayed in bed, I finally spotted it. Solution:DISP_FUNCTION(CPingerSink, "OnPingEvent", OnPingEvent, VT_EMPTY, VTS_UI4 VTS_BSTR)
There is a subtle difference. Notice the absence of the "," between VTS_UI4 and VTS_BSTR. Oh well, it is the last time I call the compiler a liar...Well for a while anyway :)Ant. I'm hard, yet soft.
I'm coloured, yet clear.
I'm fruity and sweet.
I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain) -
We can all have one of those days, this must have been one of them! Code:
DISP_FUNCTION(CPingerSink, "OnPingEvent", OnPingEvent, VT_EMPTY, VTS_UI4, VTS_BSTR)
Compiler: warning C4002: too many actual parameters for macro 'DISP_FUNCTION' A few cross words and pointing at other lines of code saying "Look, those have more parameters! What is wrong with you?". And also after a hour or so of wondering what day it was and whether I should have stayed in bed, I finally spotted it. Solution:DISP_FUNCTION(CPingerSink, "OnPingEvent", OnPingEvent, VT_EMPTY, VTS_UI4 VTS_BSTR)
There is a subtle difference. Notice the absence of the "," between VTS_UI4 and VTS_BSTR. Oh well, it is the last time I call the compiler a liar...Well for a while anyway :)Ant. I'm hard, yet soft.
I'm coloured, yet clear.
I'm fruity and sweet.
I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)Antony M Kancidrowski wrote:
Oh well, it is the last time I call the compiler a liar...Well for a while anyway :)
At least they tend to be consistent liars ;)
If you're stuck in a rut: 1) Consult the documentation* 2) Google it 3) Ask a sensible question 4) Try an ancient ritualistic knowledge summoning (:badger::badger::badger:) dance :jig: 5) Phone :bob: * - If the documentation is MSDN > 6.0 then forget it!
-
We can all have one of those days, this must have been one of them! Code:
DISP_FUNCTION(CPingerSink, "OnPingEvent", OnPingEvent, VT_EMPTY, VTS_UI4, VTS_BSTR)
Compiler: warning C4002: too many actual parameters for macro 'DISP_FUNCTION' A few cross words and pointing at other lines of code saying "Look, those have more parameters! What is wrong with you?". And also after a hour or so of wondering what day it was and whether I should have stayed in bed, I finally spotted it. Solution:DISP_FUNCTION(CPingerSink, "OnPingEvent", OnPingEvent, VT_EMPTY, VTS_UI4 VTS_BSTR)
There is a subtle difference. Notice the absence of the "," between VTS_UI4 and VTS_BSTR. Oh well, it is the last time I call the compiler a liar...Well for a while anyway :)Ant. I'm hard, yet soft.
I'm coloured, yet clear.
I'm fruity and sweet.
I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)MFC dispatch macros are particularly nasty. That particular piece of weirdness comes from the fact that C++ doesn't have varargs macros; to make it possible to build the table, the last argument is a string. This takes advantage of the fact that in C and C++, two adjacent strings in the source are concatenated together to form a single string by the compiler. The MFC
IDispatch
implementation then parses the string to figure out what the argument types are and how to pass them to the called function. ATL simply hands the whole job off to the standard type-library-based implementation ofIDispatch
. You can do this in MFC by following the steps in this KB article[^].Stability. What an interesting concept. -- Chris Maunder
-
MFC dispatch macros are particularly nasty. That particular piece of weirdness comes from the fact that C++ doesn't have varargs macros; to make it possible to build the table, the last argument is a string. This takes advantage of the fact that in C and C++, two adjacent strings in the source are concatenated together to form a single string by the compiler. The MFC
IDispatch
implementation then parses the string to figure out what the argument types are and how to pass them to the called function. ATL simply hands the whole job off to the standard type-library-based implementation ofIDispatch
. You can do this in MFC by following the steps in this KB article[^].Stability. What an interesting concept. -- Chris Maunder
Thanks for this link Mike. I will certainly need to read that through a couple of times in order to really understand it. Printing it as I type. :)
Ant. I'm hard, yet soft.
I'm coloured, yet clear.
I'm fruity and sweet.
I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain) -
We can all have one of those days, this must have been one of them! Code:
DISP_FUNCTION(CPingerSink, "OnPingEvent", OnPingEvent, VT_EMPTY, VTS_UI4, VTS_BSTR)
Compiler: warning C4002: too many actual parameters for macro 'DISP_FUNCTION' A few cross words and pointing at other lines of code saying "Look, those have more parameters! What is wrong with you?". And also after a hour or so of wondering what day it was and whether I should have stayed in bed, I finally spotted it. Solution:DISP_FUNCTION(CPingerSink, "OnPingEvent", OnPingEvent, VT_EMPTY, VTS_UI4 VTS_BSTR)
There is a subtle difference. Notice the absence of the "," between VTS_UI4 and VTS_BSTR. Oh well, it is the last time I call the compiler a liar...Well for a while anyway :)Ant. I'm hard, yet soft.
I'm coloured, yet clear.
I'm fruity and sweet.
I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)Those MFC macros are sooooooo easy to mess up, and the hell of it is that they are alway ok in the Debug Build but always crash in the Release Build ...
Regards Ray "Je Suis Mort De Rire" Blogging @ Keratoconus Watch
-
We can all have one of those days, this must have been one of them! Code:
DISP_FUNCTION(CPingerSink, "OnPingEvent", OnPingEvent, VT_EMPTY, VTS_UI4, VTS_BSTR)
Compiler: warning C4002: too many actual parameters for macro 'DISP_FUNCTION' A few cross words and pointing at other lines of code saying "Look, those have more parameters! What is wrong with you?". And also after a hour or so of wondering what day it was and whether I should have stayed in bed, I finally spotted it. Solution:DISP_FUNCTION(CPingerSink, "OnPingEvent", OnPingEvent, VT_EMPTY, VTS_UI4 VTS_BSTR)
There is a subtle difference. Notice the absence of the "," between VTS_UI4 and VTS_BSTR. Oh well, it is the last time I call the compiler a liar...Well for a while anyway :)Ant. I'm hard, yet soft.
I'm coloured, yet clear.
I'm fruity and sweet.
I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)Antony M Kancidrowski wrote:
We can all have one of those days, this must have been one of them!
That so good with those days: there are enough of them for anyone...:laugh:
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation." -- Caius Petronius, Roman Consul, 66 A.D.