Opened 8 years ago

Closed 8 years ago

Last modified 6 years ago

#10685 closed Support Requests (wontfix)

mfc_thread_init.hpp does not compile

Reported by: fab@… Owned by: Niall Douglas
Milestone: To Be Determined Component: thread
Version: Boost 1.57.0 Severity: Problem
Keywords: MFC thread Cc:

Description (last modified by viboes)

Visual Studio 2010 (SP1) error C2440: 'initializing' : cannot convert f…
…rom 'BOOL (__stdcall *)(HINSTANCE,DWORD,LPVOID)' to 'BOOL (__stdcall *const )(HANDLE,DWORD,LPVOID)' This conversion requires a reinterpret_cast, a C-style cast or function-style cast

I have submitted a pull request on github also.

Attachments (1)

mfc_thread_init.patch (645 bytes ) - added by fab@… 8 years ago.
Patch to address issue

Download all attachments as: .zip

Change History (15)

by fab@…, 8 years ago

Attachment: mfc_thread_init.patch added

Patch to address issue

comment:1 by viboes, 8 years ago

Description: modified (diff)

comment:2 by viboes, 8 years ago

Could you show the whole compile error?

comment:3 by viboes, 8 years ago

Every reference to ExtRawDllMain (https://social.msdn.microsoft.com/Search/en-US?query=ExtRawDllMain&emptyWatermark=true&ac=4) make use of HINSTANCE.

Where do you have find a declaration using HANDLE?

comment:4 by viboes, 8 years ago

Owner: changed from Anthony Williams to Niall Douglas

in reply to:  2 comment:5 by fab@…, 8 years ago

Replying to viboes:

Could you show the whole compile error?

That is the whole compile error on the line that I am changing in the patch.

in reply to:  3 ; comment:6 by fab@…, 8 years ago

Replying to viboes:

Every reference to ExtRawDllMain make use of HINSTANCE.

Where do you have find a declaration using HANDLE?

I don't know why the original author of this file used HANDLE -- you are correct in that it should have used HINSTANCE instead just about everywhere. If the "reverse" change is applied, I guess the change could break some folks who started using the HANDLE version which is currently exposed.

in reply to:  6 comment:7 by viboes, 8 years ago

Replying to fab@…:

Replying to viboes:

Every reference to ExtRawDllMain make use of HINSTANCE.

Where do you have find a declaration using HANDLE?

I don't know why the original author of this file used HANDLE -- you are correct in that it should have used HINSTANCE instead just about everywhere. If the "reverse" change is applied, I guess the change could break some folks who started using the HANDLE version which is currently exposed.

By the patch is doing the opposite. is changing HINSTANCE by HANDLE.

comment:8 by Niall Douglas, 8 years ago

DllMain, or RawDllMain, takes a HINSTANCE not a HANDLE. Whatever isn't using HINSTANCE needs to do so.

We actually have a fairly big problem here, this particular file doesn't get compiled unless the project including the header is using MFC which is surely a minority of users. I'll look into writing a new test case which switches on MFC, that should include this file into being tested from now on. I'll also fix everything up to use HINSTANCE as it should have been from the beginning.

comment:9 by Niall Douglas, 8 years ago

There is a problem.

The following MFC Extension DLL ought to be close to compiling:

// Purely to test if Boost.Thread compiles with a MFC extension DLL
#ifdef _MSC_VER
#include <windows.h>
#include <stdafx.h>
#include <afxdllx.h>
#include <boost/thread.hpp>

static AFX_EXTENSION_MODULE extensionDLL;

extern "C" int APIENTRY 
DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID)
{
   if (dwReason == DLL_PROCESS_ATTACH)
   {
      // Extension DLL one-time initialization 
      if (!AfxInitExtensionModule(
             extensionDLL, hInstance))
         return 0;

   }
   else if (dwReason == DLL_PROCESS_DETACH)
   {
      // Extension DLL per-process termination
      AfxTermExtensionModule(extensionDLL);

   }
   return 1;   // ok
}
#endif

And that would test if Boost.Thread compiles with MFC or not.

My problem is I have the Visual Studio Express free edition. I don't have the commercial one costing thousands of euro, so I don't have MFC.

Can someone else test this for me please?

Thanks, Niall

comment:10 by fab@…, 8 years ago

Guys,

Glad this is converging.

I have been under a number of deadlines, and I hope to be able to verify the "reverse" patch this week.

I will retract my patch in the meantime.

comment:11 by viboes, 8 years ago

Any news on this issue?

comment:12 by viboes, 8 years ago

Type: BugsSupport Requests

Moved to support, until there is more feedback.

comment:13 by viboes, 8 years ago

Resolution: wontfix
Status: newclosed

We need tome tester help in order to be able to fix it. Closed until we get it.

comment:14 by Keith Meadows <Keith.Meadows@…>, 6 years ago

mfc_thread_init.hpp does not compile. This still does not compile when used with MFC. The conflict is pretty obvious here as the function declaration and forward declaration/ assignment do not agree. if line 30 is changed from extern "C" declspec(selectany) BOOL (WINAPI * const _pRawDllMainOrig)(HANDLE, DWORD, LPVOID) = &ExtRawDllMain;

to extern "C" declspec(selectany) BOOL (WINAPI * const _pRawDllMainOrig)(HINSTANCE, DWORD, LPVOID) = &ExtRawDllMain;

everything compiles and runs as expected.

Note: See TracTickets for help on using tickets.