Visual Studio '97 |
© 1997 Microsoft Corporation
Other product and company names herein may be the trademarks of their respective owners.
This document includes updated information for the documentation provided with the Microsoft® Visual C++® development system, version 5.0. The information in this document and in the Help system is more up-to-date than that in the online documentation. Many of the issues outlined in this document will be corrected in upcoming releases.
Contents
Do Not Install Visual C++ 5.0 Over an Installation of Visual C++ 4.x
Protected-Mode CD-ROM Driver Required Under Windows 95 for Visual C++ Installation
Use Knowledge Base Articles to Solve Setup and Operating Problems
Applications Built with OLEAUT32.LIB Require AXDIST.EXE and/or NT SP5a
DAO Setup Requires OLEAUT32.dll 2.20.4054 or Later
Viewing "ANSI Character Code Chart" in InfoView Requires an English System
Accessing Online Help Brings Up MSN Dialog Box
Special Instructions for Installing Visual C++ 5.0 on Far East Operating Systems
Exporting Visual C++ Makefiles
Reducing the Size of Header Files for Faster Builds
Several Project System and Debugger Methods are Disabled When the BuildFinish Event is Fired
Inactive Links in the Online Documentation
Avoid Disc Swapping During Full-Text Search of the Documentation
ODBC 3.0 Programmer's Reference and SDK Guide
Error in the Scribble MDI Drawing Application Documentation
The Properties Menu Item is Now Located on the View Menu
Microsoft Oracle ODBC Driver is Missing from the "ODBC Driver List" Topic
HCW.EXE 4.01 Does Not Support Office 97
Incorrect Statement in ATL Tutorial
Visual C++ Support for Authenticode
Some ActiveX Controls Created with Visual Basic Generate Error in ActiveX Test Container on Resize
Oracle Joins and MSRDC20.OCX (Remote Data Control V2)
Current, Localized ActiveX Redistributable ComponentsLanguage Issues
Smart Pointers Example is Incorrect
Member Templates Not Supported by the Compiler
Addendums to the __declspec Documentation
Behavior of In-Constructor Exception Handling Not Correctly Documented
Size Mismatch for Type bool in Visual C++ 4.2 Programs Built with Visual C++ 5.0
Coexistence of Visual C++ 4.2 and 5.0
Incomplete Documentation for CWnd::RepositionBars
I/O Streams Now Exist in the "std" Namespace
Example Code in the CArchive::MapObject Member Function is Incorrect
ATL.DLL Replaces REGISTER.DLL
ON_WM_SETTINGCHANGE
TN024 Doesn't Identify all Custom MFC Resource Types
MFC DAO Classes will Work with Either DAO 3.0 or DAO 3.5
Using DAO with a Secure Database
The Hewlett Packard Standard Template Library
Incorrect Information in the "_spawn, _wspawn Functions" Topic
MFC Loads Wrong Resource in Extension .dll
Call _findclose After Using _findfirst or _findnext
_wgetcwd and _getcwd
_wtmpnam
Incorrect Use of TZ Environment Variable
Using the _popen Function with a Windows Program
C Runtime _expand Function Returns NULL Upon Failure
Format Specification Not Supported in COleDateTime and COleDateTimeSpan Classes
IsBadHugeReadPtr, IsBadHugeWritePtr, IsBadStringPtr, IsBadWritePtr, and Access Violations
IPropertyPageImpl::Help is implemented incorrectly.
Wizard and other User-Interface Issues
Two New Template Variables Available to Custom AppWizards
Problems with ClassWizard Generated Wrapper Classes for Visual Basic 5.0 ActiveX Servers
Newly Added Classes May Not be Displayed in the ClassView
Using ClassView to Work with ATL Classes
ATL Controls in Visual Basic 5.0 Containers
Development Environment is Unresponsive While Processing a VBScript Macro
Add Microsoft Transaction Server Libraries to your Proxy/Stub Makefile
ClassView's Add Method and Add Property Dialogs Sometimes Allow Illegal Return Types for Custom Interfaces
Microsoft Transaction Server Issues
Read Microsoft Transaction Server (MTS) Readme
MTS Doesn't Install on Windows 95
Disable Transaction Time-out While Debugging
Run Transaction Explorer Before Running Components
No Proxy/Stubs with Dual Interfaces
SQL Debugging with Visual C++ 5.0 and Microsoft Transaction Server
New Visual C++ 5.0 Samples
EXTBIND Sample Fails to Build
Get Sendtime and Settime Samples From the Compact Disc
CON Sample Fails Under MinCRT Configurations
ATLButton Sample Returns Incorrect Property Values
Typographical Error in Circle Sample Tutorial
Typo in tan and tanh Sample
ATL Polygon Sample Does Not Build in Release Mode
BINDENRL Sample Fails to Copy STDREG32.MDB
OLE DB SDK
ADO, OLE DB, and Visual C++
Remove UUID2.LIB from link line of OLE DB SDK Table Copy Sample
TableCopy Faults with Oracle Data Sources
Enabling SQL Debugging
One or More Breakpoints are Disabled Upon Starting Direct Database Debugging
ODBC SQL Server Driver Causes a Failure in CRecordset::Edit Mode
SQL Debugging Will Be Disabled Following a Lost Server Connection
SQL Debugging a Disconnected Data Connection May Produce Unexpected Results
Remote SQL Debugging with Automation Manager Registered as Interactive User
Compiler, Linker, Debugger, and MIDL Compiler
Windbg Cannot Use Visual C++ 5.0 Debugging Information.
_declspec(novtable)
_ATL_MIN_CRT and Link Error "unresolved external symbol _main"
DCOM95 Available for Distributed Applications
/WS:AGGRESSIVE (Aggressively Trim Process Memory)
/FD (Generate File Dependencies)
_MSC_EXTENSIONS Compiler Macro
Option Precedence and the CL Environment Variable
/Zm (Specify Memory Allocation Limit)
Compiler Now Documents Type Library Dependencies
Keywords _emul and _emulu Not Documented
New Linker Error: Linker Tools Error LNK1189
Benefit of Using the Linker's /OPT:ICF Option
Debugging Windows API Functions with NT Symbols Loaded
If Screen Flashes During Build or the Wrong Code Page Is Used When Debugging a Console Application
Debugger Asserts While Debugging a Console Application
Incorrect Documentation for the Clean Menu Command
MIDL2020: error generating type library: save all changes failed
Error RC2104 : undefined keyword or key name: MFT_STRING
Error Command Line Warning MIDL1009:unknown argument ignored
Additional Information on the C2065 Compiler Error
Documentation for Error C2712 Incomplete
Compiler Warning (level 4) C2498
Compiler Warning (level 4) C4238
Compiler Warning (level 3) C4800
Compiler Warning (level 1) C4804
Compiler Warning (level 1) C4805
Compiler Warning (level 1) C4806
Compiler Warning (level 1) C4807
Compiler Warnings (level 1) C4808
Compiler Warning (level 1) C4809
Converting a Project Directly From Source Control
Change in Terminology for Data View and SQL Debugging
Database Projects
Do Not Install Visual C++ 5.0 Over an Installation of Visual C++ 4.x
Installing VC++ 5.0 on top of VC++ 4.x, will render the 4.x tools unusable. Install Visual C++ 5.0 into a directory separate from your VC++ 4.x installation. VC++ 5.0 can co-exist with a 4.x installation, as long as both versions reside in different directories.
Protected-Mode CD-ROM Driver Required Under Windows 95 for Visual C++ Installation
To install Visual C++ 5.0 under Windows 95, you must be running a protected-mode CD-ROM driver. You can verify this by checking the Device Manager. If you are currently using a real-mode CD-ROM driver, contact your CD-ROM drive manufacturer for an updated driver for Windows 95 before installing Visual C++ 5.0.
Use Knowledge Base Articles to Solve Setup and Operating Problems
You can use the Knowledge Base articles in the MSDN documentation to resolve known installation and operating problems. Select the Search command from the Help menu and search for error message or related keywords to find a problem description and resolution.
Knowledge Base articles, which are written by Microsoft Technical Support Engineers, are available by connecting to http:// www.microsoft.com/kb/. Choose Visual C++ in the Choose a Microsoft product or technology drop-down list. Enter the article number in the Enter a Search Phrase text box, then click Begin Search.
Applications Built with OLEAUT32.LIB Require AXDIST.EXE and/or NT SP5a
Visual C++ 5.0 ships with the latest OLEAUT32.LIB from the ActiveX SDK which exposes entry points into the OLEAUT32.DLL which are not present in the OLEAUT32.DLL that ships with the original NT and Windows 95 operating systems. If you build an OLE-enabled application or component with Visual C++ 5.0, and link with OLEAUT32.DLL, you will need to install the newer OLEAUT32.DLL via the AXDist.exe applet located in the DevStudio\VC\Redist\AXRedist directory on the Visual C++ 5.0 CD-Rom.
If you are targeting Windows NT 3.51, you will need to ensure that NT Service Pack 5a is installed on the target machine.
DAO Setup Requires OLEAUT32.dll 2.20.4054 or Later
The redistributable DAO Setup program that ships with Visual C++ will not run successfully unless OLEAUT32.dll build 2.20.4045 or later is installed and registered on the target computer. The newer version of OLEAUT32.dll must be copied to the target machine's SYSTEM directory, and registered with REGSVR32.exe. An up-to-date version of OLEAUT32.dll can be found on the first disc of Visual C++, in the DevStudioVC\Redist directory.
Viewing "ANSI Character Code Chart" in InfoView Requires an English System
The character codes displayed in the "ANSI Character Code Chart" topic will only display correctly if viewed on English systems using an "ANSI-compatible" codepage.
Accessing Online Help Brings Up MSN Dialog Box
When accessing online help you may get a dialog box asking about your dial-up connection for your online service provider. This occurs because Internet Explorer, which has an option to automatically connect to the online service, is used to display the online documentation. The best way around this is to choose Cancel when asked to connect. You can disable automatic dialup.
To turn off the automatic dialup:
Special Instructions for Installing Visual C++ 5.0 on Far East Operating Systems
The Visual C++ installation does not copy over the localized versions of RICHED32.DLL, GAPI32.DLL, and HLP95EN.DLL on machines running a DBCS enabled Operating System. These 3 files are required by some of the ActiveX Controls installed by Visual C++.
If you install this version of VC++ on a Far East Operating System, be sure to copy these 3 files from the directory on the Visual C++ CD indicated below into your System directory:
Chinese (PRC) |
DevStudio\VC\Redist\Ocx\chs |
Chinese (Taiwan) |
DevStudio\VC\Redist\Ocx\cht |
Japanese |
DevStudio\VC\Redist\Ocx\jpn |
Korean |
DevStudio\VC\Redist\Ocx\kor |
Exporting Visual C++ Makefiles
There are a few remaining problems related to accurate exporting of makefiles. To create the most reliable exported make files with Visual C++ 5.0, first perform a BUILD for each configuration within Developer Studio, and then click the Export command on the Build menu to create external makefile(s). This will ensure that build dependencies are correctly reflected in the exported makefile(s).
Reducing the Size of Header Files for Faster Builds
To speed the build process, Visual C++ 5.0 provides the following new defines. Use them to reduce the size of the Win32 header files.
Newly generated Visual C++ AppWizard applications automatically benefit from VC_EXTRALEAN. You can also manually define VC_EXTRALEAN to speed the build process of many legacy MFC applications.
Non-MFC C++ and C applications can define WIN32_EXTRA_LEAN and any applicable NOservice defines, such as NOSOUND (see DevStudio\Vc\include\Windows.h), to reduce their build times.
To add these defines, from the Project menu, choose Settings. The Projects settings dialog box appears. Click the C/C++ tab. In the Category list, select Preprocessor. Add the desired definitions to the Preprocessor Definitions box.
Several Project System and Debugger Methods are Disabled when the BuildFinish Event is Fired.
Consider the following VBScript event handler:
Sub Application_BuildFinish(nNumErrors, nNumWarnings) if nNumErrors+nNumWarnings = 0 then ExecuteCommand "ToggleOutputWindow" ExecuteConfiguration end if End Sub
ExecuteConfiguration fails because the BuildFinish event is fired before several project system and debugger commands have been re-enabled. The methods that invoke these commands, like ExecuteConfiguration, will remain disabled between the time that the event is fired and the time the event handler returns. After the Application_BuildFinish event handler returns, these methods will be re-enabled.
Workaround
1. Create a new macro, say MyBuild with the following code:
Sub MyBuild Build ' Add other method calls here that can't appear in the BuildFinish ' event handler, such as "ExecuteConfiguration" End Sub
2. Always invoke a build by using this new macro instead of using the default Build menu command or toolbar. Note that you can create a custom menu command or toolbar button for your new MyBuild macro by going to the Tools menu, choosing Customize, and using the Commands tab of the dialog.
The Application_BuildFinish VBScript event handler now becomes:
Sub Application_BuildFinish(nNumErrors, nNumWarnings) if nNumErrors+nNumWarnings = 0 then ExecuteCommand "ToggleOutputWindow" end if End Sub
In this case Build will fire the BuildFinish event and return control to the MyBuild subroutine at which time the ExecuteConfiguration will be enabled. You can see what other methods are disabled simply by looking at the disabled menu items when a build is in progress.
Inactive Links in the Online Documentation
Certain types of links in the online documentation do not work. They look like links, but if you click them, nothing happens.
Such inactive links may be due to a setting in your Internet Explorer 3.0 that prevents running ActiveX scripts.
To enable the links, do the following:
Avoid Disc Swapping During Full-Text Search of the Documentation
The MSDN CD contains all of the online documentation for all products in Visual Studio 97. If you install MSDN and leave it in the CD drive, you will not have to swap discs to search online content.
If you chose the CD-ROM installation option when you installed Visual C++, you will need to have the Visual C++ CD in your CD ROM drive most of the time. To avoid looking for on-line content that is not on the Visual C++ CD, use the Define Subsets command from the Help menu to create a restricted search subset of the following Visual C++ documentation:
Use this subset when doing most full-text searches. Use the "Entire Contents" subset when you need to search all of the online documentation and don't care about disc swapping.
ODBC 3.0 Programmer's Reference and SDK Guide
The ODBC 3.0 documentation was not available for integration into Visual C++ 5.0 Infoviewer at the time of manufacture. (The ODBC documentation that you can find in the InfoViewer is for ODBC 2.5)
However, the following two Windows Help files (WinHlp32.exe) contain the ODBC 3.0 Programmer's Reference and the ODBC 3.0 SDK Guide:
ODBC.HLP
SDKGUIDE.HLP
These files are installed during setup in the DevStudio\SharedIDE\Help directory.
Use the following procedure to add them to the Tools menu:
Error in the Scribble MDI Drawing Application Documentation
In the topic "Create the Dialog Box," in the procedure "To create the Pen Widths dialog box," Step 3 suggests that you double-click the dialog box to bring up the dialog box property page. To bring up the property page, right-click the dialog box, and then click Properties from the menu.
The Properties Menu Item is Now Located on the View Menu
In the topics "Associating the Toolbar Button with a Command ID" and "Adding a Tool Tip" in the Scribble MDI Drawing Application, you are instructed to click Properties from the Edit menu. The Properties menu item is located on the View menu.
Microsoft Oracle ODBC Driver is Missing From the "ODBC Driver List" Topic
The list of ODBC drivers, found in the "ODBC Driver List" topic, should include the Microsoft Oracle ODBC driver.
HCW.EXE 4.01 Does Not Support Office 97
The version of Microsoft Help Workshop (HCW.exe) that is installed by Visual C++ 5 does not support .rtf files created using Office '97. If you are an Office '97 user creating .rtf files for use with the Microsoft Help Workshop, you can do one of the following:
Incorrect Statement in ATL Tutorial
The ATL Tutorial contains instructions for removing the DllMain entry point. Because the ATL COM AppWizard no longer sets DllMain as the entry point, this step is unnecessary.
Visual C++ Support for Authenticode
To find the tools necessary for packaging your ATL and MFC controls into cabinet (.cab) files and signing the resulting .cab files, look in the CAB&Sign directory. This directory is on the disc that includes "Microsoft Visual C++" on the label. (Disc 1 if you purchased Visual C++; Disc 3 if you purchased Visual Studio.)
For more information on how to use these tools, see www.microsoft.com/visualc/reference/cab.htm.
Some ActiveX Controls Created with Visual Basic Generate Error in ActiveX Test Container on Resize
Microsoft Visual Basic 5.0 supports the creation of ActiveX Controls (OCX's). Some controls that are created with Visual Basic set the OLEMISC_NOUIACTIVATE bit. If the control is inserted into the ActiveX Test Container and then is resized, the ActiveX Test Container attempts a DoVerb (OLEIVERB_UIACTIVATE) call that results in the following error:
"Failed to connect. Link may be broken."
This problem is being investigated. This does not impede hosting the control in Visual C++.
Oracle Joins and MSRDC20.OCX (Remote Data Control V2)
If you use the Microsoft ODBC Driver for Oracle with the Microsoft Remote Data Control (MRDC20.OCX) and your SQL statement contains a join (or includes a reference to a view that contains a join), you may encounter the following driver error:
"SC100: [Microsoft][ODBC Driver for Oracle]Driver not capable"
Workaround
Change the CursorDriver, LockType, and ResultsetType properties. The following settings will work:
CursorDriver = 'ODBC Cursor'
LockType = ' Optimistic Concurrency'
ResultsetType = 'Create a Static Cursor'
Current, Localized ActiveX Redistributable Components
The ActiveX redistributable components that ship with Visual C++ 5.0 were current when the product was released to manufacturing. You can always check http://www.microsoft.com/intdev/sdk/ for the most current components.Note   If your Internet application will be used in an Internet Explorer localized environment, your application should use the localized ActiveX components that are available from this site, otherwise the components contained on this CD may overwrite Internet Explorer localized components.
Smart Pointers Example is Incomplete
In the "Templates and Smart Pointers" topic, the following code does not contain an added test to prevent a smart-pointer object from being down counted out of existence should the smart pointer be assigned to itself:
Ptr &operator=(Ptr<T> &p_) // This is new { return operator=((T *) p_); }
The example should be rewritten as follows:
Ptr &operator=(Ptr<T> &p_) // This is new { if (this == &p_) { // do nothing return *this; } return operator=((T *) p_); }
Member Templates Not Supported by the Compiler
Simple member templates may not generate a compiler error. Use of member templates can result in memory leaks and undefined behavior.
Addendum to the __declspec Documentation
The documentation for the __declspec keyword is missing the following information:
Addendum One
The __declspec keywords should be placed at the beginning of a simple declaration. __declspec keywords placed after * or & and in front of the variable identifier in a declaration will be ignored by the compiler without error message or warnings. See the __declspec topic in Language Quick Reference for more information about using the __declspec attributes.
Addendum Two
The following three declarations are equivalent:
#define WINAPI __declspec(nothrow) __stdcall void WINAPI foo1(); void __declspec(nothrow) __stdcall foo2(); void __stdcall foo3() throw();
Using "void __declspec(nothrow) __stdcall foo2();" has the advantage that you can use an API definition, such as the illustrated by the #define statement, to easily specify nothrow on a set of functions. The third declaration, "void __stdcall foo3() throw();" is the syntax defined by the C++ standard.
Behavior of In-Constructor Exception Handling Not Correctly Documented
If you use the operator new without any extra arguments, and compile with the /GX, /EHs, or /EHa option, the compiler will generate code to call operator delete if the constructor throws an exception.
If you use the placement new form of the new operator, the form with arguments in addition to the size of the allocation, the compiler does not support a placement form of the delete operator if the constructor throws an exception.
Example
class A { public: A(int) { throw "Fail!"; } }; void foo(void) { try { // heap memory pointed to by pa1 will be deallocated // by calling ::operator delete(void*). A* pa1 = new A(10); } catch (...) { } try { // This will call ::operator new(size_t, char*, int). // When A::A(int) does a throw, we should call // ::operator delete(void*, char*, int) to deallocate // the memory pointed to by pa2, but that's something // we don't support yet, so we'll leak memory. A* pa2 = new(__FILE__, __LINE__) A(20); } catch (...) { } }
Size Mismatch for Type bool in Visual C++ 4.2 Programs Built with Visual C++ 5.0
In Visual C++4.2, the Standard C++ header files contained a typedef that equated bool with int. In Visual C++ 5.0, bool is implemented as a built-in type with a size of 1 byte. That means that for Visual C++ 4.2, a call of sizeof(bool) yields 4, while in Visual C++ 5.0, the same call yields 1. This can cause memory corruption problems if you have defined structure members of type bool in Visual C++ 4.2 and are mixing object files (OBJ) and/or DLLs built with the 4.2 and 5.0 compilers.
Coexistence of Visual C++ 4.2 and 5.0
The Visual C++ 4.2 and 5.0 library DLLs have the same names. Setup for Visual C++ 5.0 will overwrite your 4.2 system files. Debug information has changed in Visual C++ 5.0 and is not compatible with the Visual C++ 4.2 debugger. Because of this, the Visual C++ 4.2 debugger will not be able to step into the source code of the Microsoft Visual C++ 5.0 MFC or CRT debug libraries. This issue will not affect Visual C++ 4.0 or 4.1 users and does not affect your ability to debug your own source code.
Affected files:
Workarounds
These files are on your Visual C++ 4.2 compact disc in the \MSDEV\DEBUG directory.
None of these workarounds allows debugging of Release Builds with 4.2 debugger.
NOTE to MFC42b (patch) customers. If you need to recreate the patched MFC DLLs, we have provided the MFC4.2B patch (MFC42B.EXE ) in the \DevStudio\Vc\Debug directory. This directory is on the disc that includes "Microsoft Visual C++" on the label. (Disc 1 if you purchased Visual C++; Disc 3 if you purchased Visual Studio.) You can patch the MFC files by copying them into a temporary directory and running the patch on them. You can ignore the errors about missing files.
The Visual C++ 5.0 files will not otherwise affect the operation of Visual C++ 4.2. Under no circumstances do we recommend replacing the new versions of mfc42.dll, mfc42u.dll, and msvcrt.dll with the versions from 4.2 as you may break other applications dependent on the new versions of these DLL's. The Visual C++ 5.0 Developer Studio will not run with the VC++ 4.2 version of mfc42.dll.
Incomplete Documentation for CWnd::RepositionBars
The documentation for CWnd::RepositionBars is missing the parameter bStretch. The prototype should read:
void RepositionBars( UINT nIDFirst, UINT nIDLast, UINT nIDLeftOver, UINT nFlag = reposDefault, LPRECT lpRectParam = NULL, LPCRECT lpRectClient = NULL, BOOL bStretch = TRUE );
bStretch indicates whether the bar should be stretched to the size of the frame.
I/O Streams Now Exist in the "std" Namespace
Per Section 27 of the new ANSI draft, streams are now defined within the std namespace. This means that any program that uses I/O streams must reference the streams within the scope of std.
For example, the following sample will fail to compile, because cout is defined in the std namespace, unless the third line is uncommented:
// file Test.cpp #include <iostream> // using namespace std; void main() { cout << "Hello ANSI Committee" << endl; } // end file Test.cpp
Example Code in the CArchive::MapObject Member Function is Incorrect
In the section SubItem.cpp of the code, nonexistent overloaded CDocument operators (<< and >>) are used in two places. This code section should be replaced with the following code:
//SubItem.cpp void CSubItem::Serialize(CArchive& ar) { if (ar.IsStoring( ) ) { // will serialize a reference // to the "mapped" document pointer ar << (CObject *)m_pDoc; ar << m_l; } else { // Will load a reference to // the "mapped" document pointer ar >> (CObject *&) m_pDoc; ar >> m_l; } }
Register.dll, which shipped with Visual C++ Beta 1, has been replaced with Atl.dll. To use the new DLL with your existing ATL projects you will simply need to rebuild them.
The windows message map entry ON_WM_SETTINGCHANGE corresponds to the MFC member function with this prototype:
afx_msg void OnSettingChange( UINT uFlags, LPCTSTR lpszSection );
Parameters
uFlags |
When the system sends the message as a result of a SystemParametersInfo call, this parameter is a flag that indicates the system parameter that was changed. For a list of values, see the SystemParametersInfo function in the Win32 Programmers Reference. When an application sends the message, this parameter must be 0. |
lpszSection |
Points to a string that specifies the name of the section that has changed. (The string does not include the square brackets that enclose the section name.) |
Remarks
The framework calls OnSettingChange for all top-level windows when the Win32 SystemParametersInfo function changes a system-wide setting. An application should send the message to all top-level windows when it makes changes to system parameters, and Windows will send the message if the user changes settings via the Control Panel.
The ON_WM_SETTINGCHANGE message is similar to the ON_WM_WININICHANGE message, with the following difference:
You should have only one of these macros in your message map. To write a program that works for both Windows 95 and Windows NT 4.0, write a handler for ON_WM_SETTINGCHANGE. Under Windows NT 3.51, your handler will be called by uFlags will always be zero.
See Also SystemParametersInfo and WM_SETTINGCHANGE in the Win32 Programmers Reference, and ON_WININICHANGE and CWnd::OnWinIniChange in the MFC Reference.
TN024 Doesn't Identify all Custom MFC Resource Types
MFC Technote TN024, titled "MFC-Defined Messages and Resources", states that:
"There is currently only one MFC private resource format defined, RT_DLGINIT."
This statement should read:
"Currently, MFC defines two private resource formats: RT_DLGINIT and RT_TOOLBAR."
The default toolbar supplied by AppWizard is based on an RT_TOOLBAR custom resource, which was introduced in MFC 4.0.
You can edit this resource with the toolbar editor.
MFC DAO Classes will Work with Either DAO 3.0 or DAO 3.5
However the MFC DAO classes have not been designed to take advantage of any new DAO 3.5 features, including ODBCDirect.
Using DAO with a Secure Database
If you are writing a program that uses Data Access Objects DAO to access a secure database, you will receive an error if you use CDaoRecordset because MFC does not prompt the user for a user name and password. To find out how to call DAO directly to implement DAO security features, such as changing user passwords, see Technical Note 054 in the Microsoft Foundation Class Reference. The title is "TN054: Calling DAO Directly While Using MFC DAO Classes."
The Hewlett Packard Standard Template Library
Visual C++ 5.0 ships a complete, fully supported C++ Standard Run-time Library, that includes the Microsoft implementation of the Standard Template Library.
Setup installs the new C++ Standard Run-time Library with the other run-time libraries.
Note The Hewlett Packard Standard Template Library that shipped with Visual C++ 4.0 does not ship with Visual C++ 5.0. Microsoft does not provide technical support for the Hewlett Packard version of the Standard Template Library.
Incorrect Information in the " _spawn, _wspawn Functions" Topic
In the topic titled "_spawn, _wspawn Functions", a table in the Remarks section has wrong information. The table is labeled "Generic-Text Routine Mappings." The far right column of the table, which has the heading "_UNICODE Defined," should list all the _wspawn functions instead of the spawn functions. When the _UNICODE flag is defined, the wide-character (_w) versions of the functions are used.
MFC Loads Wrong Resource in Extension .dll
The wrong resource is loaded when CBitmap::LoadBitmap, CMenu::LoadMenu, CString::LoadString or any other MFC resource-loading function is called in an MFC extension .dll (AFXDLL). In some cases, a resource in the application is loaded instead of the appropriate resource in the extension .dll.
When a resource in the application or another extension .dll gets loaded instead of a resource in the current extension .dll, the cause is usually improper resource management. An MFC application and all of its extension DLLs are one global chain of resources. If there are multiple resources with the same ID value in any of the modules in the chain, MFC uses the first resource it finds with the desired ID value. The first resource is often found in the application, which is searched before any of the extension DLLs.
Change the ID values of any conflicting resources so they are unique in both the application and any extension .dll that the application uses. These values are stored in the Resource.h file for each project and can be modified in the Resource Editor or in Developer Studio with the Resource Symbols command.
To ensure that modules do not use conflicting symbol values, reserve different ranges of ID values for each module in the 1 through 0x6FFFF range. Set the _APS_NEXT_RESOURCE_VALUE definition in the Resource.h file for each module to the low end of that module's range before creating any resources. The Resource Editor uses this symbol to determine the ID value of the next resource created.
This technique is documented in MFC Technical Note 35 and in the DLLHUSK sample included with Visual C++.
In .exe or .dll files that link to MFC dynamically, MFC resource-loading functions call AfxFindResourceHandle to obtain the handle of the module where a resource is located. AfxFindResourceHandle searches for resources by type and symbol value in:
Note Some 16-bit MFC resource loading functions do not call AfxFindResourceHandle, but instead use the value returned from AfxCurrentResourceHandle.
Each extension .dll creates, initializes, and then passes a CDynLinkLibrary object to AfxInitExtensionModule that places the .dll in the resource chain. AfxTermExtensionModule removes the .dll from the chain when the .dll is detached from the application.
A benefit of this design is that MFC automatically locates a resource for an application or extension .dll, even if that resource is located in a distant extension .dll or the application itself. All resources in the process are chained, so ID values are passed between DLLs and the application and the proper resources are loaded. A disadvantage is that there are no duplicate ID values between any of the extension DLLs or the application that uses them.
To set the default location where AfxFindResourceHandle first checks for a resource, use AfxSetResourceHandle. Because AfxFindResourceHandle first checks the handle set by AfxSetResourceHandle, it can be used to circumvent the chain and load a resource from one particular .dll or application. The resource handle is restored to its original value immediately after loading the resources. The current default resource handle is found with AfxGetResourceHandle.
The DLLHUSK sample included with Visual C++ also illustrates this technique. In Testdll2.cpp, CListOutputFrame::Create sets the resource handle to the module handle stored in the AFX_EXTENSION_MODULE structure extension .dll. This structure is initialized with the module handle when it is passed to the CDynLinkLibrary constructor in InitTestDLL2.
For information on:
Call _findclose After Using _findfirst or _findnext
You must call _findclose after you are finished using either the _findfirst or _findnext function. This will free up resources used by these functions in your application.
The documentation for _getcwd and _wgetcwd should describe the second parameter (maxlen) as follows:
maxlen Maximum length of path in characters- char for _getcwd and wchar_t for _wgetcwd
The documentation for should include the following:
If string is not NULL, it is assumed to point to an array of at least L_tmpnam characters--or 2*L_tmpnam bytes. The value of L_tmpnam is defined in STDIO.H.
Incorrect Use of TZ Environment Variable
The online documentation for the _tzset function incorrectly defines the time bias for the TZ environment variable parameter (tzn) as being the "offset from UTC." It should define it as being the "offset from local time to UTC." The example for German time zone should be:
set TZ=GST-1GDT
Using the _popen Function with a Windows Program
The _popen function, from the C Runtime Library, returns an invalid file handle if used in a Windows program which causes the program to hang indefinitely. It works properly in a Console application.
To create a Windows application that redirects input and output, read the section "Creating a Child Process that Redirects Input and Output" in the Win32 SDK.
C Runtime _expand Function Returns NULL Upon Failure
The _expand function returns NULL when an error is detected during operation. This may happen when there is sufficient memory. The current documentation implies that failures occur only when there is insufficient memory to expand the memory block. This is incorrect. For example, when _expand is used to shrink a memory block, it might detect a corruption in the small block heap or an invalid block pointer, and returns NULL.
Format Specification Not Supported in COleDateTime and COleDateTimeSpan Classes
The description of the member function Format in both the COleDateTime and the COleDateTimeSpan erroneously states that you can use the %D format specification to display the number of days. Neither COleDateTime::Format nor COleDateTimeSpan::Format support that format specification.
IsBadHugeReadPtr, IsBadHugeWritePtr, IsBadStringPtr, IsBadWritePtr, and Access Violations
A handled exception will occur inside of these functions if the specified memory region is not accessible to the process when these functions attempt to access it. If the code is being executed under a debugger, and the debugger is configured to get first chance at handling exceptions, the debugger will trap the access violation and stop program execution. At this point you can simply continue execution in the debugger and these functions will return the appropriate value. This behavior can help you find potential access violations in your code.
IPropertyPageImpl::Help is implemented incorrectly.
In most cases, if you are using property pages, you should override IPropertyPage::Help and return E_NOTIMPL. This will cause the container to use information returned from GetPageInfo. You can also provide your own alternative implementation of this function if necessary.
Two New Template Variables Available to Custom AppWizards
root_oem |
Same as 'root' except translated to the OEM character set. Affects only upper ASCII characters in the project name (such as an umlauted character). |
HM_FILE_OEM |
Same as 'HM_FILE' except translated to the OEM character set. Affects only upper ASCII characters in the project name (such as an umlauted character). |
The Visual C++ tools work with the ANSI character set. Batch files, such as makehelp.bat, work with the OEM character set--a legacy from the days of DOS 1.0 that still exists. Most printable characters in these two sets are the same. However, there are some differences in some of the upper ASCII values used for European characters such as those that use an umlaut.
Problems with ClassWizard-Generated Wrapper Classes for Visual Basic 5 ActiveX Servers
With Visual Basic 5.0 you can create ActiveX Automation servers with methods that can take Optional and Default parameters of any Visual Basic intrinsic type. If you use MFC and want to access an object of a Visual Basic ActiveX Automation server, you would, typically, use ClassWizard to read the type information of the Visual Basic object and generate a class that wraps the functionality of the Visual Basic Automation object. C++ does not have optional or default parameters and so the wrapper class that ClassWizard generates will not mark parameters as Optional or Default.
For example, if you have a Visual Basic Server with the following function:
Function function2(Optional parm1 As Integer = 5) MsgBox parm1 End Function
ClassWizard will generate the following C++ wrapper function:
VARIANT _MyVBObj::function2(short* parm1) { VARIANT result; static BYTE parms[] = VTS_PI2; InvokeHelper(0x60030001, DISPATCH_METHOD, VT_VARIANT, (void*)&result, parms, parm1); return result; }
If you call the ClassWizard generated function from your MFC program, you will have to pass the argument even though Visual Basic marked it as Optional.
Workaround
Override the function that ClassWizard generates with versions of the function that take only the parameters you wish to pass. For example, in the preceding case, if you didn't want to pass the optional parameter, override the ClassWizard generated function as follows:
VARIANT _MyVBObj::function2() { VARIANT result; InvokeHelper(0x60030001, DISPATCH_METHOD, VT_VARIANT, (void*)&result, NULL); return result; }
In the preceding case, the default parameter for the Visual Basic server's function2 would be used.
Newly Added Classes May Not be Displayed in the ClassView
Dependency scanning in VC++ 5.0 has changed from earlier versions of Visual C++. Only files that are in the project will be scanned by ClassView. The External Dependency folder is automatically populated by the IDE and is not considered part of your project. If you want to see classes from header files that are in the External Dependencies folder, insert that file into your project. One easy way to insert a file from the External Dependencies folder is by dragging and dropping it into the project.
Using ClassView to Work with ATL Classes
You can customize ClassView to work with ATL classes. In the editor, open SYSINCL.dat (which resides in DEVSTUDIO\SHAREDIDE\BIN), add ATL files to it (e.g., atlcom.h, atlbase.h, atlimpl.cpp, etc.), and save it as MSVCINCL.dat to your %windows% directory. You can remove MFC files from MSVCINCL.dat.
ATL Controls in Visual Basic 5.0 Containers
If you're using the IQuickActivate interface in Visual Basic 5.0, you must also support IPropertyNotifySink.
To use a control generated by the ATL Object Wizard in a Visual Basic 5.0 container, you must either add support for IPropertyNotifySink or remove dependence on the IQuickActivate interface. To remove IQuickActivate support, comment out the lines containing IQuickActivateImpl in the control's class inheritance list and in the COM interface map.
For example, if you generate a Full Control called MyCtl with the ATL Object Wizard, then go to MyCtl.h and comment out the line containing IQuickActivateImpl in the CMyCtl class inheritance list:
class ATL_NO_VTABLE CMyCtl : ... // public IQuickActivateImpl<CMyCtl>
Also, comment out the line containing IQuickActivateImpl in the COM interface map in MyCtl.h:
BEGIN_COM_MAP(CMyCtl) ... // COM_INTERFACE_ENTRY_IMPL(IQuickActivate)
Development Environment is Unresponsive While Processing a VBScript Macro
The Visual C++ user interface does not respond to mouse clicks or keystrokes until a macro finishes. Processing a lengthy macro gives the appearance that the user interface has hung. This design prevents indiscriminate interference between macros.
Add Microsoft Transaction Server Libraries to Your Proxy/Stub Makefile
If you are using a separate Proxy/Stub DLL created with the ATL COM Wizard, add the library mtxih.lib as the first library in to the link line.
ON_MESSAGE(WM_PAINT, OnPaint) ON_MESSAGE(WM_GETDLGCODE, OnGetDlgCode) ON_MESSAGE(WM_SETFOCUS, OnSetFocus) ON_MESSAGE(WM_KILLFOCUS, OnKillFocus)
To correct the problem, delete the four lines before building your control.
ClassView's Add Method and Add Property Dialogs Sometimes Allow Illegal Return Types for Custom Interfaces
The return type dropdown for Add Method and Add Property should only be active for dispinterfaces and custom interfaces with the attribute 'local'. The return type is fixed at 'HRESULT' for all other interface definitions (such as dual). Unfortunately, it is active for all non-dual interfaces. If you change the return type to something other than 'HRESULT' for a property or method in a custom interface that doesn't have the 'local' attribute on it, the midl compiler will fail with error 2269 when you build your project.
Feature Only in Enterprise Edition The Microsoft Transaction Server is supported only in Visual C++ Enterprise Editions.
Read Microsoft Transaction Server (MTS) Readme
After installing Microsoft Transaction Server, please consult the Microsoft Transaction Server readme file, located in the docs subdirectory of the Microsoft Transaction Server installation. The file contains information required to install, configure and run program components. The readme also contains descriptions of several useful samples and includes a list of known problems.
MTS Doesn't Install on Windows 95
The Beta version of Microsoft Transaction Server does not run on Windows 95. If you attempt to install it, you will get a message box stating that 'the setup did not complete.' No files or registry keys are affected.
Disable Transaction Time-Out While Debugging
Microsoft Transaction Server uses a time-out mechanism to keep components from deadlocking the system. If the transaction time-out is enabled while you are debugging the component, the transaction context may be destroyed, causing a protection fault. To avoid this, you can disable this time-out from the Microsoft Transaction Server Explorer. Select the My Computer icon and select its properties. Under the options tab on the properties dialog box, you will see a transaction time out section. To disable the timeout, set the timeout to 0.
Run Transaction Explorer Before Running Components
Microsoft Transaction Server components are inproc COM servers. Most inproc COM servers require that you run a utility called REGSVR32.exe. The utility places important information about the server into the systems registry. The default build step for MFC and ATL COM servers is to run REGSVR32.exe before completing the build.
Microsoft Transaction Server components are different as they need special registry keys in order to execute. This means that you should run the Microsoft Transaction Server Explorer and install or import the component before executing it. Running REGSVR32.exe after installing or importing the component will change some of the registry keys and will prevent your component from running properly. There are two ways to get around this:
No Proxy/Stubs with Dual Interfaces
The Microsoft Transaction Server Beta software is not capable of inheriting interfaces. The usual example of this is dual interfaces. Dual interfaces inherit from the IDispatch interface. If you create a Microsoft Transaction Server component that uses dual interfaces, you must use type libraries to contain the interface information. If you build a proxy/stub marshaling .dll for your dual interface component, you will get errors from Microsoft Transaction Server. See the Microsoft Transaction Server Readme for more information.
SQL Debugging with Visual C++ 5.0 and Microsoft Transaction Server
You can perform SQL debugging through Microsoft Transaction Server Components. In this case, the component usually calls a stored procedure via ODBC or any other data-access methodology. The component needs to be running locally on the debugging machine as an inproc server. If the component is running remotely on a different machine or as a local server, you will be unable to engage the SQL debugging components. You will also not be able to perform SQL debugging if the transaction started on a different machine as part of the DTC functionality from SQL Server/Microsoft Transaction Server.
To do SQL debugging, follow these steps:
You should hit the breakpoints in your stored procedures and should be able to debug them normally. If you have problems, ensure that you can debug the stored procedure directly (i.e. select debug stored procedure instead of running it through the component). Also, make sure that Microsoft Transaction Server is functioning properly. See the Microsoft Transaction Server README for further installation steps.
Feature Only in Enterprise Edition The Microsoft Visual Data Tools are supported only in Visual C++ Enterprise Editions.
See the Visual DataTools readme.
The samples on the first Visual C++ CD are accessible from any directory browser (Explorer or File Manager, for example). Sample code remains available for viewing and download from sample abstracts in the documentation.
Try out the samples located in the \DEVSTUDIO\VC\SAMPLES directory of the first Visual C++ CD. These include examples of using the new compiler support for COM and samples for ATL. They also include a new Custom AppWizard sample.
If you build the EXTBIND sample without having MDIBIND sample in a sibling directory, the compilation process will fail.
Workaround
Add the .cpp file to the directory where the EXTBIND sample resides.
Get Sendtime and Settime Samples From the Compact Disc
The files for the Sendtime and Settime samples downloaded from the Enterprise sample abstracts in the online documentation will not compile.
Workaround
Manually copy the correct files for these samples from the DevStudio\VC\Samples\Ent\time directory. This directory is on the disc that includes "Microsoft Visual C++" on the label. (Disc 1 if you purchased Visual C++; Disc 3 if you purchased Visual Studio.)ATLCON Sample Fails Under MinCRT Configurations
To successfully run the ATL sample, ATLCON, under a MinCRT configuration, you must remove the WinMain entry point as follows:
ATLButton Sample Returns Incorrect Property Values
The ATLButton sample returns incorrect values for the properties ImageHover and ImagePush. To correct the sample change the file AtlButton.h so that the function get_ImageHover uses m_bstrFilename[1].Copy() and change get_ImagePush so that is uses m_bstrFilename[2].Copy().
Typographical Error in Circle Sample Tutorial
In the topic "Creating the Basic Control," the first class name in the table that describes the class templates created by ControlWizards is incorrect. The correct class name is CCircApp.
Class |
Files |
Comments |
CCircApp |
CIRC.H |
Implements the main DLL source. Typically, there is no need to modify this code. |
In the documentation of tan and tanh, there is a typo in the sample. The current sample shows:
printf( "tan( %f ) = %f\n", x, y ); printf( "tanh( %f ) = %f\n", y, x );
It should be:
printf( "tan( %f ) = %f\n", pi/4, x ); printf( "tanh( %f ) = %f\n", x, y );
The correct output is:
tan( 0.785398 ) = 1.000000 tanh( 1.000000 ) = 0.761594
See both the \DEVSTUDIO\VC\SAMPLES and the \OLEDB\SAMPLES directories on the first Visual C++ CD.
ATL Polygon Sample Does Not Build in Release Mode
The ATL Polygon Sample does not build in Release mode as it incorrectly defines the _ATL_MIN_CRT macro.
Workaround
BINDENRL Sample Fails to Copy STDREG32.MDB
To build the BINDENRL sample, you'll need to manually copy the database file stdreg32.mdb into the same local directory that you copy the samples source files. You will find stdreg32.mdb in the DEVSTUDIO\VC\Samples\mcl\mfc\database\daoenrol directory. This directory is on the disc that includes "Microsoft Visual C++" on the label. (Disc 1 if you purchased Visual C++; Disc 3 if you purchased Visual Studio.)
Feature Only in Enterprise Edition The OLE DB SDK is supported only in Visual C++ Enterprise Editions.
OLE DB is a set of OLE interfaces that provides applications with uniform access to data stored in diverse information sources. These interfaces support the amount of DBMS functionality appropriate to the data source, enabling it to share its data. To learn more about OLE DB, please refer to the SDKGUIDE.hlp, OLEDB1.hlp, and RELNOTES.DOC files located in the \OLEDB\DOC directory on the disc.
To install the OLE DB SDK, run the SETUP.exe program located in the OLEDB folder in the root of the Visual C++ compact disc.
ADO is an object model on top of the OLE DB interfaces. It reduces the number of interfaces required to implement an application. ADO also provides a type library which OLE DB does not. If you wish to use OLE DB with the new compiler COM support, you must write to ADO.
Visual C++ 5.0 ships two versions of ADO. The beta version in the OLE DB SDK and the shipping version in redist\ado. Use the shipping version to build and test your application before releasing it. You must also distribute the shipping version of ADO with your application.
Remove UUID2.LIB from link line of OLE DB SDK Table Copy Sample
The TableCopy sample in the OLE DB SDK 1.1 will not compile correctly with Visual C++ 5.0. You will receive a link error stating that UUID2.LIB is not found. This is because UUID.LIB, UUID2.LIB, and UUID3.LIB have been combined in Visual C++ 5.0 in the UUID.LIB file. To fix the build problem, go to project settings for the sample, select the link tab, select all configurations, and remove the UUID2.LIB entry from the Obect/Library Modules line. You should then be able to successfully compile and link this sample.
TableCopy Faults with Oracle Data Sources
The TableCopy sample will not function correctly with an Oracle data source. Select a different data source type to use this sample.
Feature Only in Enterprise Edition SQL and SQL debugging are supported only in Visual C++ Enterprise Editions.
To enable SQL Debugging, you need to install the Visual C++ Enterprise Edition Server Components on your SQL Server machine. Before you run the setup program for the VC Server Components, you must first install the latest Service Pack for Windows NT, and the latest Service Pack for Microsoft SQL Server. Once these service packs are installed, you will be able to successfully install the Visual C++ Server Components. The setup program can be run directly from the VCServer directory, or from the master setup program in the root directory of Disc 2 (Disc 4 for Visual Studio).
One or More Breakpoints are Disabled Upon Starting Direct Database Debugging
If your workspace includes both a C++ and a database project it is possible to encounter a message that warns of one or more break points being disabled when you begin debugging the database. This happens when you have C++ breakpoint set in your C++ project and you begin debugging the database project before the C++ project. In some cases, the debugger will not be able to find the C++ symbols. The workaround is to first begin debugging the C++ project, which allows the debugger to load the C++ symbols, before you debug the database project.
ODBC SQL Server Driver Causes a Failure in CRecordset::Edit Mode
The ODBC SQL Server driver (06.50.0240) that ships with the Visual C++ Enterprise Edition has a change in behavior that may cause a failure in CRecordset::Edit mode during the call to CRecordset::Update.
Workaround
SQL Debugging Will Be Disabled Following a Lost Server Connection
If the SQL Server against which you are debugging fails during an SQL Debugging Session, you can reestablish the connection to the database. Go to the View menu and use the Refresh command.
SQL Debugging a Disconnected Data Connection May Produce Unexpected Results
IIf you delete or disconnect a data connection during a SQL Debugging session you may find the IDE in an unstable state. It is recommended that you do not delete or disconnect a data connection while you are using SQL Debugging. Stop Debugging before you delete or disconnect the data connection.
Remote SQL Debugging with Automation Manager Registered as Interactive User
If you install SQL Server and then install Visual C++ Enterprise Edition (including the Visual C++ Enterprise server-side components) on the same computer, the automation manager's identity is registered as "Interactive User." In this scenario, if you log off from this machine but keep SQL server running as a service, you will not be able to remote debug against this server. Registering the automation manager's identity as "Interactive User" necessitates that someone be logged onto the computer to remotely debug SQL.
Visual C++ setup registers the Automation manager as Interactive User, when installed with a preexisting SQL Server, with the assumption that you'll want to do local SQL debugging. Local debugging cannot occur if the automation manager's identity is registered as "Launching User" (the default) and SQL server and automation manager are already running in the service environment.
To change the identity that the automation manager recognizes:
Windbg Cannot Use Visual C++ 5.0 Debugging Information.
Because of changes to the format of debugging information in Visual C++ 5.0, you will not be able to use the Windbg debugger (distributed in the NT 4.0 Win32 SDK) to do source level debugging of programs created with Visual C++ 5.0.
This form of _declspec can be applied to any class declaration, but should only be applied to pure interface classes, i.e. classes that will never be instantiated on their own. The _declspec stops the compiler from generating code to initialize the vfptr in the constructor(s) and destructor of the class. In many cases, this removes the only references to the vtable that are associated with the class and, thus, the linker will remove it. Using this form of _declspec can result in a significant reduction in code size.
_ATL_MIN_CRT and Link Error "unresolved external symbol _main"
When you build an ATL project with the Win32 MinDependency configuration, you can get the following link error:
LIBCMT.LIB(crt0.obj) : error LNK2001: unresolved external symbol _main
This error occurs if you are using CRT functions that require CRT startup code. The MinDependency project configuration defines _ATL_MIN_CRT, which excludes CRT startup code from your EXE or DLL.
To avoid this error, do one of the following:
DCOM95 Available for Distributed Applications
The Microsoft Distributed COM (DCOM) files for Windows 95 are useful for creating distributed applications. Some Visual C++ 5.0 samples require DCOM. You can find DCOM95 on Microsoft's OLE Web site, http://www.microsoft.com/ole. Check out the Visual C++ 5.0 Compiler COM support and ATL with DCOM95.
/WS:AGGRESSIVE (Aggressively Trim Process Memory)
Use this linker option to add the WS_AGGRESSIVE attribute to your application's image. The Windows NT 4.0 loader will recognize this attribute and aggressively trim the working set of the process when it is not active. Using this option is similar to adding the following call throughout your application.
SetProcessWorkingSetSize(hThisProcess, -1, -1)
/WS:AGGRESSIVE can be used for applications that must have a low impact on the system's memory pool.
If the speed of your application is important, do not use /WS:AGGRESSIVE without testing the resulting performance implications. Ideal candidates are processes that tend to operate in the background, such as services and screen savers.
/FD (Generate File Dependencies)
The development environment's build system uses the /FD option to ensure that the most reliable dependency information is used when it builds your project.
_MSC_EXTENSIONS Compiler Macro
This macro is defined unless you compile with /Za for ANSI compatibility. Its value, when defined, is 1.
Option Precedence and the CL Environment Variable
Compiler options are processed "left to right", and when a conflict is detected, the last (right-most) option wins. The CL environment variable is processed before the command line, so in any conflicts between CL and the command line, the command line takes precedence.
/Zm (Specify Memory Allocation Limit)
The compiler uses a number of discrete heaps, each of which has a finite limit. The total of the size limits for all heaps is about 105 MB, but when any one heap is exhausted, the compiler cannot continue. Memory is allocated only as needed; the 105 MB limit is just to keep from using too much memory. Exceeding any one of the discrete-heap size limits occurs only in rare circumstances involving very large or very complex programs. Should your program exceed one of these limits, use /Zm to scale the total size of all the limits. For example, when /Zm200 is specified, the total of all heap size limits is 210MB.
Compiler Now Documents Type Library Dependencies
The compiler provides the full path to any typelib dependency required by the typelib it is currently processing. The path is written, in the form of comments, into the typelib header (.TLH) that the compiler generates for each processed typlib.
If a typelib includes references to types defined in other typelibs, then the .TLH file will include comments of the following sort:
// // Cross-referenced type libraries: // // #import "c:\path\typelib0.tlb" //
The actual filename in the #import comment is the full path of the cross-referenced typelib, as stored in the registry. If you encounter errors that are due to missing type definitions, check the comments at the head of the .TLH to see which dependent typelibs may need to be imported first. Likely errors are syntax errors (e.g. C2143, C2146, C2321), C2501 (missing decl-specifiers), or C2433 ('inline' not permitted on data declaration) while compiling the .TLI file.
You must determine which of the dependency comments are not otherwise provided for by system headers and then provide an #import directive at some point before the #import directive of the dependent typelib in order to resolve the errors.
Keywords _emul and _emulu Not Documented
Syntax:
_int64 _emul(long, long);
unsigned _int64 _emulu(unsigned long, unsigned long);
Use these keywords to efficiently multiply two 32-bit integer numbers, which return a 64-bit result.
New Linker Error: Linker Tools Error LNK1189
LIBTOOMANYMEMBERS:: library limit of number objects exceeded
The limit of 65535 objects or members in a library has been exceeded.
Benefit of Using the Linker's /OPT:ICF Option
The /OPT:ICF[,iterations] option removes identical COMDAT records in order to reduct the size of the executable produced by the linker. The iterations value specifies the number of times to repeat the search for identical COMDAT records. If /OPT:REF is specified, /OPT:ICF is on by default unless you specify /OPT:NOICF as well.
Debugging Windows API functions with NT Symbols Loaded
If you have the NT symbols loaded and you want to debug Windows API functions, you need to enter the decorated name of the function while setting a breakpoint on the function. For example, if you want to set breakpoint on the MessageBeep function, use the decorated name _MessageBeep@4. The decorated name can be obtained in the map file created through linker options.
If Screen Flashes During Build or the Wrong Code Page is used When Debugging a Console Application
If you are using Windows 95, delete any of the following files from your computer:
These files were used by Windows 3.x, and are not needed by Windows 95. If they are used, while you are debugging a console application, the country settings associated with the PIF files will be used, and could result in the wrong code page being loaded. A result of their use on Windows 95 may be screen flashing during a Build, if you have specified console windows to be full screen.
Debugger Asserts While Debugging a Console Application
If you are debugging a console application and the debugger is stopped at a break, use the Stop Debugging command to stop the debugger and unload the console application. Using the console window's Close button, the "x" in the upper right corner, is not recommended. If you use the Close button, the debugger might not be able to terminate the application correctly.
Incorrect Documentation for the Clean Menu Command
The Clean command is incorrectly documented in the "Remove Intermediate Files" topic as follows:
"You can remove all files from the intermediate directories in any project configuration in your project workspace."
In actuality, the Clean command will not remove precompiled header (.PCH) files. This is by design, as the initial generation of .PCH files is time consuming. If the project is a server project that has been registered on the system, the registry entries will not be cleaned up. The final result of the of using the Clean command is to delete all executable (.EXE), dynamic link library (.DLL), and Control (.OCX) files.
MIDL2020: error generating type library: save all changes failed
This error can result if the path to the .IDL file is longer than 126 characters, which is because oleaut32.dll does not currently support path names that are greater than 126 characters. The workaround is to reduce the path to the .IDL file so that it is less than 126 characters.
Error RC2104 : undefined keyword or key name: MFT_STRING
If you encounter this error, open MCL\MFC\Include\AfxRes.h and add the following include directive:
#include <winresrc.h>
Error Command Line Warning MIDL1009 : unknown argument ignored
MIDL.exe version 3.01.75 generates this error if its arguments are passed in a response file and one of the arguments is an MBCS-character file name that contains a space.
Workarounds
Use a batch file to invoke MIDL with its arguments.
Delete the space from the MBCS file name.
Additional Information on the C2065 Compiler Error
The following information belongs in the tips section of the C2065 compiler error:
Make sure you're using proper namespace scope. For example, in order to properly resolve ANSI C++ Standard Library functions and operators, you must state that you're using the std namespace with the using directive.
For example, unless the using directive is uncommented, the following sample will fail to compile because the cout stream is defined in the std namespace:
#include <iostream> // using namespace std; void main() { cout << "Hello" << endl; }
Documentation for Error C2712 Incomplete
The documentation for this error should also contain the following information:
The error can be avoided when using the /GX option by not having local variables or parameters with types that have destructors in a function that uses structured exception handling (SHE). Furthermore, SEH cannot be used in constructors or destructors if using /GX. Code that requires SEH can also be moved to another function in order to avoid the error.
C2498 : "%$S' 'novtable' can only be applied to class declarations"
For example, using __declspec(novtable) with a function, as follows, is illegal:
void __declspec(novtable) f() {
}
Compiler Warning (level 4) C4238
nonstandard extension used : class rvalue used as lvalue
This error occurs when you are using Microsoft language extensions (/Ze) and use a class type as is an rvalue in a context that implicitly or explicitly takes its address. For example:
struct C { C(); }; C * pC = &C(); // yields C4238
This usage is not permitted by the C++ Working Paper, and in some cases (such as the example above) can be quite dangerous. This usage is being permitted under /Ze for compatibility with previous versions of the compiler, which did not flag this error. This usage is not permitted under /Za.
Compiler Warning (level 3) C4800
'type' : forcing value to bool 'true' or 'false' (performance warning)
This warning is generated when some non-bool value is assigned or coerced into type bool. To solve this problem, change the type of the value being assigned to bool. Typically, this message is caused by int types that should be bool.
Compiler Warning (level 1) C4804
'%$L' : unsafe use of type 'bool' in operation
This warning is generated when you used a bool variable or value in an ambiguous way. For example: i << b, -b, b+=i, b/=b, b%=i, etc.
Note It's OK to use a bool value as the left side of a shift operator, eg: "b << count". This is for unary operations.
Compiler Warning (level 1) C4805
'%$L' : unsafe mix of type 'type' and type 'type' in operation
This message is similar to C4804, and it is limited to binary operations. It is generated for operations such as b &= i.
Compiler Warning (level 1) C4806
'%$L' : unsafe operation: no value of type 'type' promoted to type 'type' can equal the given constant
This message warns against serious errors such as b == 3. The promotion rules cause bool to be promoted to int. This is legal according to the working papers, but it can never be true.
Compiler Warning (level 1) C4807
'%$L' : unsafe mix of type 'type' and signed bitfield of type 'type'
No warnings are generated about mixing bool and 1-bit bitfields since they are identical to bool (can only hold 0,1). The exception to this is signed bitfields. A comparison such as if( s.sbit1 == b ) does not work as expected, and this warning is generated. This is because it is comparing (1,0) vs. (0,1).
Compiler Warnings (level 1) C4808
case '%d' is not a valid value for switch condition of type 'bool'
This warning is generated when types other than true and false are stored in bool variables, and accessed in a switch statement.
Compiler Warning (level 1) C4809
switch statement has redundant 'default' label; all possible 'case' labels are given
This message is generated in places where you have both 'true' and 'false' cases, in addition to a default label to bool.
Converting a Project Directly From Source Control
Visual C++ no longer allows you to open an old project from source control and convert it to the new project format from within Visual C++. Use the SourceSafe Explorer (or equivalent source control interface) to get the files to a local disc, then open the project in Visual C++ to do the conversion, and then check the files back in to source control. After this you may open the project out of source control as usual from Visual C++.
Change in Terminology for Data View and SQL Debugging
In the context of Data View and SQL Debugging in Visual C++ 4.2 Enterprise Edition, the term "Data Source" was used to describe the set of data that a database application accesses. In Visual C++ 5.0 Enterprise Edition, this term was changed to "Data Connection" to be consistent with terminology used across Visual Studio Products.
In Visual C++ 4.2 Enterprise Edition, you could add a Data Source to any type of Visual C++ project by selecting Data Source from the Insert menu.
In Visual C++ 5.0 Enterprise Edition, a new project type has been created to allow more effective management of Data Connections. The new project type is called a Database Project. Data Connections can only be added to Database Projects by selecting Add to Project, then Data Connection from the Project menu.
For more information about working with Database projects, see the following sections of the online documentation: