Visual C++ Express Edition Gotchas
Moving from VC6 to Visual C++ Express Edition has thrown up some issues (and no doubt will continue to do so). The following table lists the main problems (and their solutions) I’ve encountered so far. The really nice thing is that these problems could be easily anticipated and users warned, but hey, where’s the fun in that?
I ran into a few problems during installation and when compiling my existing code for the first time. I found that solutions to installation problems were adequately covered on the MS web-site. Solutions to compilation problems were a bit more difficult to find, hence this page…
I use Microsoft because it’s what I use at work and it’s the de facto “industry standard”. Over time I plan to dabble with other free compilers…
I switched from Visual C++ 6.0 (VC++6) to Visual C++ Express Edition (VCEE), it’s free so I ain’t complaining. I’ve also installed the Windows SDK and MSDN, again both available free from MS. The MSDN is a wonderful resource blighted by a truly appalling interface and filters that don’t work (the “developers” should be mightily ashamed of themselves). Bizarrely, the SDK is labelled “Microsoft Platform SDK for Windows Server 2003 SP1”, but no, that is the latest version and the one to download and install.
Summary
Error, warning or problem | Solution |
---|---|
foo.cpp(18035) : warning C4996: 'function' was declared deprecated | Disable appropriate warning detail… |
error C2664: 'CreateWindowExW' : cannot convert parameter 2 from 'const char [10]' to 'LPCWSTR' | Set project defaults to use Multi-Byte Character Set (MCBS) detail… |
error C2440: '=' : cannot convert from 'const char [10]' to 'LPCWSTR' | Set project defaults to use Multi-Byte Character Set (MCBS) detail… |
RC1015: cannot open include file 'afxres.h' | Edit resource file manually detail… |
Express does not allow the editing of resources | Use third party editor then include manually detail… |
Run time error: Couldn't run application because MSVCR80D.dll couldn't be found/is missing. |
Link statically to the C run-time (CRT) using the /MT compiler switch detail…
This is a re-distribution issue. See Running a very simple Win32 app on a comp without VC++ 2005 Express |
Detail
warning C4996: 'function' was declared deprecated
Fix
either
Project → Properties → Configuration Properties → C/C++ → Preprocessor
add
to Preprocessor Definitions
or
<Tool Name="VCCLCompilerTool" PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE"/>
to Visual Studio 8\VC\VCProjectDefaults\corewin_express.vsprops inside the VisualStudioPropertySheet tags. (The CoreWin.vsprops file should be Read-Only, so you may have to change its file properties before saving.)
Comments
Not portable! Not portable! Not portable!
Nice.
I’d read about the “deprecation” issue around the web. Apparently MS know better and have greater authority than the C++ standards committee (which is nice to know) so this little ditty breaks the perfectly valid code of thousands of developers. Yay! Go Redmond!
error C2664: 'CreateWindowExW' : cannot convert parameter 2 from 'const char [10]' to 'LPCWSTR'
error C2440: '=' : cannot convert from 'const char [10]' to 'LPCWSTR'
Fix
Set to use Multi-Byte Character Set
Comments
RC1015: cannot open include file 'afxres.h'
Fix
// Microsoft Visual C++ generated resource script. // #include "resource.h" #define APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 2 resource. // #include "afxres.h" ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // English (U.K.) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG) #ifdef _WIN32 LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK #pragma code_page(1252) #endif //_WIN32 #ifdef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // TEXTINCLUDE // 1 TEXTINCLUDE BEGIN "resource1.h\0" END 2 TEXTINCLUDE BEGIN "#include ""afxres.h""\r\n" "\0" END 3 TEXTINCLUDE BEGIN "\r\n" "\0" END #endif // APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // Icon // // Icon with lowest ID value placed first to ensure application icon // remains consistent on all systems. IDI_ICON1 ICON "icon1.ico" #endif // English (U.K.) resources ///////////////////////////////////////////////////////////////////////////// #ifndef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 3 resource. // ///////////////////////////////////////////////////////////////////////////// #endif // not APSTUDIO_INVOKED
most of which isn’t needed. The preceding can be replaced with:
#include "resource.h" IDI_ICON1 ICON "icon1.ico"
Comments
Express does not allow the editing of resources
Fix
Comments
Couldn't run application because MSVCR80D.dll couldn't be found/is missing
Fix
Project → Properties → Configuration Properties → C/C++ → Code Generation → Runtime LibrarySet the /MT option.
Comments
Let’s just consider this for a minute, select “release build” then click build and you get an exe you CAN’T release.
Hmmm… so once again… set the release build option… y’know so you can build an exe to give to OTHER people who probably won’t have any Visual Studio tools installed, click build and Express builds an exe… that y’know OTHER people on entirely DIFFERENT computers CAN’T USE!!!
So, no warnings, no instructions, no options, no indication that Express will not do what you’ve asked for, no indication of how to do it, nothing. Quick check in the dictionary for the definition of contempt… a-a-and… no, no mention of MicroSoft’s attitude towards their customers.
The truly staggering thing to me is that someone sat down and decided that this was a GOOD idea! Take a moment, if you will, and picture a conference room full of Redmond’s finest; slumped, slack jawed, vacant eyed and drooling, barely able to remember how to breathe when some genius pipes up “Programmers never really want to share their work with anyone else ever. So, when they ask for a release exe they don’t really want a release exe. So, we should cripple it and not tell then… hur, hur, hur.” before succumbing to an aneurysm as his synapses collapse under the strain of actually having a thought (no matter that it’s total pants). Several days later, half-starved and wild-eyed they finally remember how to exit the room (thank God the door wasn’t closed or they wouldn’t have made it out alive). Determined that their fellow shall not have died in vain they will implement his idea… er… whatever it was…
I must admit I’m particularly pissed off because I’ve been sending out copies of a simple demo app to show off my programming prowess and now I find that they probably won’t work on the target machines. So, MS have made me look more like a programming retard than a programming demi-god. Thanks a big fat hairy bunch guys… that plumbing job is starting to look mighty fine…
Moral: don’t trust those arrogant asses at MS…
Disclaimer: All opinions expressed here are just that; my opinions; and are in no way intended to criticise Microsoft, its staff or products…
no matter how poor that may actually be.