Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

error C2731: 'DllMain' : function cannot be overloaded

680 views
Skip to first unread message

GuyS

unread,
Nov 11, 2008, 10:00:11 AM11/11/08
to
Hi,
I realy need your help....
After converting my VC6 C++ Dll to VS2005 WinCE6 C++ Dll, i got the following
errors
error C2731: 'DllMain' : function cannot be overloaded
error C2733: second C linkage of overloaded function 'DllMain' not allowed

I have implementet the following entry point in my code:
(it seems like i have 2 more entry points which i really don't know about
them)

HINSTANCE ghInstance;
extern "C"
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID
/*lpReserved*/)
{
ghInstance = hInstance;
return TRUE;
}

Could you please advise?

Thanks in advance,
Guy.

Paul G. Tobey [eMVP]

unread,
Nov 11, 2008, 10:32:19 AM11/11/08
to
Your declaration of DllMain doesn't match the one in the Windows header
files, so the C++ compiler is treating this as a C++ construct, having two
functions of the same name with different parameter lists, but since DllMain
is declared as extern "C", you can't do that, hence the error. Here's what
I see in the header files:

BOOL
WINAPI
DllMain (
HANDLE hinstDLL,
DWORD dwReason,
LPVOID lpvReserved
);

Your declaration should match this (with the addition of extern "C", of
course).

Paul T.

"GuyS" <u47509@uwe> wrote in message news:8d088655c5a30@uwe...

Luca Calligaris

unread,
Nov 11, 2008, 10:33:00 AM11/11/08
to
you have the error beacuse the CE C runtime DllMain is

BOOL WINAPI DllMain( HANDLE hInstDll, DWORD fdwReason, LPVOID lpvReserved)

Change the prototype in your code

--

Luca Calligaris
l.calliga...@eurotech.it.nospam
www.eurotech.it

"GuyS" <u47509@uwe> ha scritto nel messaggio news:8d088655c5a30@uwe...

GuyS via PocketPCJunkies.com

unread,
Nov 12, 2008, 1:30:13 AM11/12/08
to
Thanks guys for you quick response,
It actually solve the problem but now I'm facing a new one.
Error 160 error LNK2005: DllMain already defined in corelibc.lib(dllmain.obj)
uafxcwd.lib
Error 161 fatal error LNK1169: one or more multiply defined symbols found

Could you please advise?


Luca Calligaris wrote:
>you have the error beacuse the CE C runtime DllMain is
>
>BOOL WINAPI DllMain( HANDLE hInstDll, DWORD fdwReason, LPVOID lpvReserved)
>
>Change the prototype in your code
>

>> Hi,
>> I realy need your help....

>[quoted text clipped - 21 lines]
>> Thanks in advance,
>> Guy.

--
Message posted via PocketPCJunkies.com
http://www.pocketpcjunkies.com/Uwe/Forums.aspx/wince-programming/200811/1

Luca Calligaris

unread,
Nov 13, 2008, 4:53:02 AM11/13/08
to
the problem is that the DLL entry point is defined in both the CE C runtime
library (corelib.c) and uafxcwd.lib.
The latter is the unicode MFC static library; maybe during the (automatic?)
conversion this library has been added
implicity to your project.

--

Luca Calligaris
l.calliga...@eurotech.it.nospam
www.eurotech.it

"GuyS via PocketPCJunkies.com" <u47509@uwe> ha scritto nel messaggio
news:8d10a542ac96f@uwe...

Guy

unread,
Nov 20, 2008, 2:23:01 AM11/20/08
to
Could you please advise how the get rid of the MFC static library?
(I already removed the adequate header "stdafx.h")
Thanks in advance,
Guy.
0 new messages