Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compile time error C4407

We have the following class structure in our code

Class A: public CDialog, public Base1, public Base2
{
};

In implementation of Class A we have the following:

BEGIN_MESSAGE_MAP( A, CDialog )
    ON_WM_SIZE()
END_MESSAGE_MAP()

Please note Base1 and Base2 doesn't inherit from CDialog or any other MFC classes.

On VC6 the compilation is successful. But on VC9 we get the following error code:

error C4407: cast between different pointer to member representations, compiler may generate incorrect code.

This error code is pointing to the location of ON_WM_SIZE.

Could anyone possibly tell me a solution. Thanks in advance.

Gamer

like image 777
gamer_rags Avatar asked Jan 22 '23 16:01

gamer_rags


2 Answers

I just solved an instance of this problem; found this question with a web search.

In my case I also had a dialog class inheriting from more than one class: CDialog and ConfigurationTab, which is an internal interface. The compiler warning was silenced by changing:

class Foo : public ConfigurationTab, public CDialog

with:

class Foo : public CDialog, public ConfigurationTab

We discovered this situation when the offending dialog crashed inside a ON_BN_CLICKED method at an assignment to a DDX variable. The DDX variable was mysteriously uninitialized at that line, when we were sure it was initialized.

like image 136
Pedro Lamarão Avatar answered Feb 24 '23 05:02

Pedro Lamarão


I don't have an installed V9 handy, but i can see that between VS6 and VC8 the ON_WM_SIZE define has changed to be semantically the same but far more stringent in what it accepts. VC6 used C casts, where VC8 is using C++ casts which catch more problems.

We would need to see the actual declaration from your class of the OnSize method i think to be able to determine what is going wrong here.

like image 37
Ruddy Avatar answered Feb 24 '23 03:02

Ruddy