Scoots
2009-08-14 21:44:09 UTC
Hello,
Sorry for the rather indescript subject, but I have a problem that's
rather difficult to state. I have an application where my main class
is declared globally. I've inherited this code, and it's quite large,
so I don't question why, I've just left it that way.
It looks something like the following:
CSimApp theApp;
in the header, the definition for CSimApp looks like:
class CSimApp
{
.
. Bunch of stuff
.
PRINTDLG m_PageSetupDlg;
PRINTDLG m_PrintDlg;
.
. More Stuff
.
CPointDatabase m_PointDB;
}
Where CPointDatabase was a class I wrote and the details of which
should not matter. If they do, I'll see what I can do to post it.
It's a few lists, etc. Not a real database. Anyway, this structure
causes thApp instance to be initialized at startup (as it is globally
defined), and, as m_PointDB is a member variable and not a pointer, it
gets initialized at the very beginning of the CSimApp constructor.
None of this should be surprising, but I discovered that the address
of &theApp.m_PointDB (in the CSimApp constructor) and "this" (inside
the CPointDatabase constructor) were 4 bytes different. So after some
debugging, I went "aha! I have two different class definitions for
something in CSimApp, " as I had just spent a fair bit of time
removing old code that was no longer used in the new app, I thought it
was highly possible for me to have introduced two definitions.
But it turns out that it is PRINTDLG. Each PRINTDLG causes 2 bytes of
offset to appear between the two pointers, which should be the same.
As soon as I remove the PRINTDLG member variables, the issue
disappeared.
Now, PRINTDLG is a defined in Windows.h, I think (or at least, you get
access by including it), and I ran a search and I do NOT have any
other definition for PRINTDLG. What's going on here? How is the size
showing up as different? And it's not just a debug mode "oops," my
object fails a afx mem check with a null pointer, caused by the
offset.
Thanks, and this isn't urgent, as I don't need printing yet. Just a
"what's going on?"
~Scoots
Sorry for the rather indescript subject, but I have a problem that's
rather difficult to state. I have an application where my main class
is declared globally. I've inherited this code, and it's quite large,
so I don't question why, I've just left it that way.
It looks something like the following:
CSimApp theApp;
in the header, the definition for CSimApp looks like:
class CSimApp
{
.
. Bunch of stuff
.
PRINTDLG m_PageSetupDlg;
PRINTDLG m_PrintDlg;
.
. More Stuff
.
CPointDatabase m_PointDB;
}
Where CPointDatabase was a class I wrote and the details of which
should not matter. If they do, I'll see what I can do to post it.
It's a few lists, etc. Not a real database. Anyway, this structure
causes thApp instance to be initialized at startup (as it is globally
defined), and, as m_PointDB is a member variable and not a pointer, it
gets initialized at the very beginning of the CSimApp constructor.
None of this should be surprising, but I discovered that the address
of &theApp.m_PointDB (in the CSimApp constructor) and "this" (inside
the CPointDatabase constructor) were 4 bytes different. So after some
debugging, I went "aha! I have two different class definitions for
something in CSimApp, " as I had just spent a fair bit of time
removing old code that was no longer used in the new app, I thought it
was highly possible for me to have introduced two definitions.
But it turns out that it is PRINTDLG. Each PRINTDLG causes 2 bytes of
offset to appear between the two pointers, which should be the same.
As soon as I remove the PRINTDLG member variables, the issue
disappeared.
Now, PRINTDLG is a defined in Windows.h, I think (or at least, you get
access by including it), and I ran a search and I do NOT have any
other definition for PRINTDLG. What's going on here? How is the size
showing up as different? And it's not just a debug mode "oops," my
object fails a afx mem check with a null pointer, caused by the
offset.
Thanks, and this isn't urgent, as I don't need printing yet. Just a
"what's going on?"
~Scoots