FIX: No Error Given for Non-static Callback Member Function (148789)
The information in this article applies to:
- Microsoft Visual C++, 32-bit Editions 4.1
- Microsoft Visual C++, 32-bit Enterprise Edition 4.2
- Microsoft Visual C++, 32-bit Professional Edition 4.2
This article was previously published under Q148789 SYMPTOMS
The compiler does not generate any compiler errors when a non-static member
function is used as a callback function and the calling convention for the
function is explicitly specified. For example, the sample code shown in
this article will not cause the compiler to generate any compiler errors
although it should.
Debugging the non-static member callback function will reveal the stack is
corrupted. Any parameters to the function, including the implied this
pointer may be invalid.
RESOLUTION
By design, a member function used as a callback function must be static. A
non-static member function cannot be used as a callback function. You can
also use file scope global functions for callback functions.
STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed
at the beginning of this article. This bug was corrected in Visual C++
version 5.0.
Modification Type: | Minor | Last Reviewed: | 7/5/2005 |
---|
Keywords: | kbBug kbcode kbCompiler kbfix kbProgramming kbVC500fix KB148789 |
---|
|