WTL problem/bug with VC7 (VS.NET)

Sorry if this has been posted before, I just found this bug and it took me a while to figure it out. Just wanted to make sure everyone was aware of the problem.

I've found a weird inconsistancy about how the compiler in VC7 (VS .NET) compiles static member class functions, specifically how the result affects WTL [7]. If you would like to test this "inconsistent behavior", create a property sheet in WTL, and have some of its pages come from a DLL that's load-time dynamically linked, and others be declared within the primary app that links to the DLL (I am testing this by having the latter have a dependency on the former). In VC6, this worked. However, in VC7, it does not. Here's the reason why:

It seems that static class member functions in VC7 are all LINKED TOGETHER. IE if I have some class A (In WTL, let's say the CDialogImpl class), and class B inside my EXE (one of my property pages) inheriting from A, and class C inside my DLL (also a property page) also inheriting from A. Also, let's say that A has a static member function StaticAFunc() (In WTL, the function is StartDialogProc). In VC6, the way that the linker would do this is it would create an instance of StaticAFunc() in the EXE, and another instance of the function inside of the DLL. Wasteful? Yes, somewhat. However, because WTL is dependent on the _Module global object, the above is REQUIRED. The reason for this is that the correct globals table (ie for the DLL or EXE) must be accessed. In VC7, only ONE instance of the static member function is created, namely inside the DLL.

So, sounds good right? Only have one copy of a function that's the same anyway (it's declared in a .H file that's included by both the EXE and the DLL). Here's where it gets weird. Normal GLOBAL functions (ie not members of a class) are NOT implemented in this way. E.G. to work around the WTL problem, all that must be done is to make the StartDialogProc function not be a member variable of the CDialogImpl class, and everything works. What's going on here? Why did Microsoft make static CLASS MEMBER functions so special? Shouldn't global functions behave the same way as a static class member function?
[2270 byte] By [marquinho] at [2007-11-18 17:44:32]
# 1 Re: WTL problem/bug with VC7 (VS.NET)
[moved]
Andy Tacker at 2007-11-9 12:02:37 >
# 2 Re: WTL problem/bug with VC7 (VS.NET)
I run into the same problem. Does anybody know of any other way to work around? I don't want to change CDialogImpl class.
Thanks
Thao at 2007-11-9 12:03:38 >