Skip to content

New MFC App with ATL, VC6.0

OK, so we’re still using VC6.0.   Gluttons for punishment, I guess.

I recently created a new MFC app and had some… opportunities getting it to compile, so I thought I’d document them here for the three other people in the world not on VC9.

First: when you start a new MFC app and switch the project-level #define of _MBCS to UNICODE,_UNICODE, then compilation suddenly breaks with the error “msvcrtd.lib(crtexew.obj) : error LNK2001: unresolved external symbol _WinMain@16″.  Solution: add /entry:”wWinMainCRTStartup” to the linker command line in the text area under the Link tab.  In newer versions of VC, there is an “Advanced” linker tab that allows you to do this through the dialog interface.  Not present in VC6.

Second: when you add ATL to your MFC project (Insert | New ATL Object… ; click Yes on the dialog, then click cancel.  Now you’re cooking with ATL even though you have no ATL objects.)  Suddenly your debug builds don’t compile anymore.  Problem: the project-level #define of _CRTDBG_MAP_ALLOC causes errors like this:

Compiling…

StdAfx.cpp

c:\program files\microsoft visual studio\vc98\include\malloc.h(105) : error C2059: syntax error : 'constant'

c:\program files\microsoft visual studio\vc98\include\malloc.h(105) : error C2733: second C linkage of overloaded function '_calloc_dbg' not allowed

c:\program files\microsoft visual studio\vc98\include\malloc.h(105) : see declaration of '_calloc_dbg'
Solution: remove the _CRTDBG_MAP_ALLOC from your Project Settings and add it to your stdafx.h after your ATL headers.

Post a Comment

Your email is never published nor shared. Required fields are marked *
*
*