====================================================================== Microsoft(R) Product Support Services Application Note (Text File) SC0626: Miscellaneous C Questions & Answers ====================================================================== Revision Date: 10/92 No Disk Included The following information applies to Microsoft C/C++ Compiler versions 6.0 and 7.0. -------------------------------------------------------------------- | INFORMATION PROVIDED IN THIS DOCUMENT AND ANY SOFTWARE THAT MAY | | ACCOMPANY THIS DOCUMENT (collectively referred to as an | | Application Note) IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY | | KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO | | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A | | PARTICULAR PURPOSE. The user assumes the entire risk as to the | | accuracy and the use of this Application Note. This Application | | Note may be copied and distributed subject to the following | | conditions: 1) All text must be copied without modification and | | all pages must be included; 2) If software is included, all files | | on the disk(s) must be copied without modification [the MS-DOS(R) | | utility DISKCOPY is appropriate for this purpose]; 3) All | | components of this Application Note must be distributed together; | | and 4) This Application Note may not be distributed for profit. | | | | Copyright 1992 Microsoft Corporation. All Rights Reserved. | | Microsoft and MS-DOS are registered trademarks and Windows | | is a trademark of Microsoft Corporation. | -------------------------------------------------------------------- 1. Q. When I compile my program, Microsoft C/C++ Compiler version 7.0 generates one of the following error messages: C1060 "Out of far heap space," C1059 "Out of near heap space," or D2027 "Cannot execute." How can I avoid these error messages? A. These error messages are typically caused by low memory conditions. We recommend that you have a minimum of 3 MB of extended memory free when you compile any application. To provide the compiler with more memory, we recommend that you do at least one of the following: a. If you are running the compiler in Microsoft Windows, increase the Windows swap-file space. For more information about increasing the swap-file space, please refer to the "Microsoft Windows User's Guide." b. Make more memory available by removing device drivers and other applications that you are executing from the CONFIG.SYS and AUTOEXEC.BAT files. For example, you may need to remove SMARTDRV.EXE or reconfigure it to use less memory. c. Decrease the value of the KEEPMEM editor setting in the Programmer's WorkBench. d. Specify the /m command line option when you invoke the NMAKE utility. 2. Q. Why do I receive L2029 "Unresolved external" errors when I try to build an application that uses a graphics function? A. Most graphics functions supplied with the Microsoft C/C++ Compiler version 7.0 package are included in a library called GRAPHICS.LIB. When you call a graphics function, you must link explicitly with the GRAPHICS.LIB library. If you are using Programmer's WorkBench, you can add the GRAPHICS.LIB library to the Additional Global Libraries selection in the LINK OPTIONS area. If you are building your project from a makefile, you should include the GRAPHICS.LIB library in the library field on the link command line. 3. Q. Why does the linker continue generating the error L1101 "Invalid Object Module"? A. Determine what version of the linker (LINK.EXE) you are using. To do this, look at the logo displayed by the linker. If you are using Microsoft C/C++ Compiler version 7.0, you should be using linker version 5.3 or later. If you have an earlier version of LINK.EXE, check for other files called LINK.EXE in the directories specified in the PATH environment variable. Earlier versions of the linker cannot recognize object modules built with the Microsoft C/C++ Compiler. NOTE: For versions of the Microsoft C Compiler prior to 7.0, making the C directories first on your path causes the correct version of the linker to be found. 4. Q. When I link my program, I receive an L2029 "Unresolved external" error. How do I call a C routine from a C++ program? A. C functions and data can be accessed in a C++ module only if they are previously declared as having C linkage. For more information about linking a C++ module with a C module, please refer to page 36 in the C++ "Language Reference" manual provided with the Microsoft C/C++ Compiler version 7.0 package. 5. Q. My Windows executable (.EXE) file or dynamic-link library (.DLL) works when I build it using the Microsoft C version 6.0 Compiler; however, when I build the .DLL with Microsoft C/C++ Compiler version 7.0, the .EXE or .DLL file fails to function correctly. How can I correct this problem? A. If you use either the new /GA or the /GD switch when you compile with Microsoft C/C++ Compiler version 7.0, you must explicitly qualify exported functions with the _EXPORT keyword or use the /GEf command line option. For more information about the options /GA, /GD, and /GEf, please refer to pages 515 and 516 of the "Environment and Tools" manual and the ERRATA1.TXT file. 6. Q. When I run Programmer's WorkBench under Windows, it generates random system integrity errors. Why is this occurring? A. Some terminate-and-stay-resident (TSR) applications can cause system integrity errors when you are running Programmer's WorkBench or other C/C++ utilities. Remove all TSRs and special device drivers from your AUTOEXEC.BAT and CONFIG.SYS files to help alleviate this problem. 7. Q. How can I convert the Microsoft C Compiler version 6.0 time value to the time value used in the Microsoft C/C++ Compiler version 7.0 time function? A. Microsoft has changed the time function in Microsoft C/C++ Compiler 7.0. The Microsoft C/C++ Compiler 7.0 time function returns the time in the number of seconds since December 31, 1899; the C Compiler 6.0 time function returns the time in the number of seconds since January 1, 1970. To convert from one format to the other, add or subtract 2,209,075,200 seconds, which is the difference between December 31, 1899 and January 1, 1970. 8. Q. What can cause NMAKE to generate the error message U1045 "Spawn failed: no space on device"? A. NMAKE may generate the U1045 error message, "Spawn failed: no space on device" if not enough expanded or extended memory is available or not enough disk space is free in the directory specified by the TMP environment variable. To correct this problem, try to make more memory and disk space available. You may also want to use the /m NMAKE option to tell NMAKE to swap itself to disk. 9. Q. I have compiled and linked my Windows-based application using Microsoft C/C++ Compiler version 7.0 with CodeView information; however, when I run CodeView for Windows, CodeView indicates that the file has no symbolic information. Why is this occurring? A. If you are running CodeView from the SDK program group in Windows, it is version 3.7 and cannot understand the CodeView 4.0 information that Microsoft C/C++ Compiler 7.0 produces. You must use CodeView for Windows 4.0 from the Microsoft C/C++ Compiler 7.0 program group. If you are using the correct version of CodeView, an incorrect version of LINK or CVPACK may be getting called and is creating incorrect debugging information. You should be using LINK version 5.3 and CVPACK version 4.0. When you link your program, the banners displayed should show these version numbers. If you are building a Windows-based application, you must also be using the Resource Compiler version 3.1; otherwise, symbolic information will be lost. 10. Q. Whenever I run Microsoft C/C++ Compiler version 7.0 under Microsoft Windows 3.1, I receive the error message R6914 "DOSX32: Cannot initialize device: VPFD.386." Why is this occurring? A. The SYSTEM.INI file in the Windows directory is not loading all the necessary devices. If you ran Setup from Windows but chose not to modify the Windows SYSTEM.INI file, the changes Setup made to that file were put in the SYSTEM.C70 file in the C700\INIT directory. To load the correct devices, copy the SYSTEM.C70 file to the Windows directory and then rename it SYSTEM.INI. If you ran Setup or C Setup from MS-DOS instead of Windows, the changes must be added by hand and the .386 files must be copied from the Setup disks using C Setup and the copy single file option. The lines that were changed and then added to the [386 enh] section are as follows: device=C:\C700\BIN\VPFD.386 device=C:\C700\BIN\CVW1.386 device=C:\C700\BIN\VMB.386 device=*vmcpd If any other line in the [386 enh] section contains VMCPD, remove that line.