lor OS/2® User's Guide Borland® C++ for OS/2® Version 1.5 Redistributable files You can redistribute the following files in accordance with the No Nonsense License Statement: • BIDS402.DLL • TCLASS2.DLL • C215.DLL • BIDS402D2.DLL • C215MT.DLL • BPMCC.DLL • LOCALE.BLL Borland may have patents andbr pending patent applications covering subject matter in this document. The furnishing of this document does not give you any license to these patents. COPYRIGHT © 1987, 1994 by Borland International. All rights reserved. All Borland products are trademarks or registered trademarks of Borland International, Inc. Other brand and product names are trademarks or registered trademarks of their respective holders. Borland International, Inc. 100 Borland Way, Scotts Valley, CA 95066-3249 PRINTED IN THE UNITED STATES OF AMERICA 1E OR0294 9495969798-987654321 H1 Contents Introduction 1 Default files 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 29 What's in Borland C++ Changing project files 0000000000000000000; 0 001 0 0 0 0 0 • 0 0 0 0 0 0 0 0 0 0 0 0 0 30 Hardware and software requirements Syntax highlighting 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 30 The Borland C++ implementation Configuring element colors 00000000000003 0 0 0 0 0 0 0 0 0 0 0 0 0 0 30 The Borland C++ package Some basic tasks 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 31 The User's Guide Compiling and linking programs 000000000000000000000000003 0000000000031 The Tools and Utilities Guide Making an application 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 0000.0000000000000 31 The Programmer's Guide Building an application 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 5 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 31 The Library Reference Compiling a file 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 31 Typefaces and icons used in these books Linking a file 0 0 0 0 0 0 0 0 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 32 Tools in your package Debugging an application 0000000000000000000000007 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 32 Contacting Borland Preparing your application . 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8 0 0 0 0 0 0 0 0 0 0 0 0 0 32 Borland Assist plans Debugging environment 00 0 0 0 0 0 0 0 0 00 0 0 0 0 0 0 0 0 0 0 0 8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 33 Viewing data objects Chapter 1 Installing Borland C++ 11 0 0 0 0 0 0 • 0 0 0 0 0 0 0 0 0 0 0 0 0 34 Controlling program execution Using INSTALL 11 0 0 0 0 0 0 0 0 0 0 0 34 Running the ID0E 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 Chapter 3 Menus and options reference 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 13 37 Opening the README file File menu 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 13 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 37 The HELPME!.DOC file New 00000000000000000000013 00000000000000000000000000000000000037 Customizing the IDE Open 00000000000000000000000014 0000000000000000000000000000000000037 Sample programs Using the File list box 00000000000000000000000000014 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 38 Save Chapter 2 IDE basics 00000000000000000000000000000000000038 15 Save As Starting the IDE 00000000000000000000000000000000038 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 15 Save All Startup options 00000000000000000000000000000000038 000000 0 0 0 0 0 0 0 0 0 000000000000 17 Print The Ib option 000000000000000000000000000000.0000039 0000000000000000000000000017 Exit The 1m option 000000000000000000000000000000000000039 000000000000000000000000017 Closed File Listing Exiting the IDE 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 39 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 17 Edit menu IDE components 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 39 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 18 Undo The menu bar and menus 0000000000000000000000000000000000041 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 18 Redo Mouse shortcuts Cut 0 0 000000000000000000000000000000000041 Using the SpeedB0a0r0 00000000000000000000019 000000000000000000000000000000000000041 00000000000000000000019 Copy Keyboard shortcuts 0000000000000000000000000000000000041 00000000000000000000021 Paste Borland C++ windows 0000000000000000000000000000000000041 0000000000000000000023 Clear Window management 0000000000000000000000000000000000041 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 25 Search menu The status line 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 41 000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 026 Find Dialog boxes 00000000000000000000000000000000000041 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 26 Replace Action buttons 00000000000000000000000000000000043 000000000000000000000000026 Search Again Radio buttons and check boxes 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 44 0000000000027 Go to Line Number Input and list boxes 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 44 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 27 Run menu Configuration and project files 00000000000000000000000000000000044 00000000000000028 Run The configuration file 00000000000000000000000000000000000044 00000 0 0 0 0 0 0 0 0 0 0 0 0 000 028 Using the same source code Project files 0 0 0 0 0 0 0 0 0 0 0 0 0 0 44 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 28 Using modified source code The project directory 0000000000000 44 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 29 Step Over Desktop files 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 45 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 29 Trace Into ............................... 45 Arrange Icons ............................ 53 Run To Cursor ........................... 45 Close All ................................ 53 Reset .................................... 45 Open Windows Listing ................... 53 Run Arguments .......................... 45 Help menu ................................ 54 Compile menu ............................. 46 Contents ................................ 55 Compile ................................. 46 Index ................................... 55 Make ................................... 46 Topic Search ............................. 56 Link .................................... 46 Essentials ............................... 56 Build All ................................ 46 Language Reference ...................... 56 Break ................................... 47 Error Messages .......................... 56 Debug menu ............................... 47 Tasks ................................... 56 Breakpoints .............................. 48 Menus .................................. 56 Messagepoints ........................... 48 Keyboard ............................... 56 Datapoints ............................... 48 Using Help .............................. 56 Exceptionpoints .......................... 48 About Borland C++ ....................... 57 Source .................................. 48 Chapter 4 Settings notebook 59 Disassembly ............................. 48 Using the Settings notebook ................. 59 Variable ................................. 48 Getting around .......................... 59 Call Stack ................................ 48 Organization ............................ 60 Watch ................................... 49 Changing and saving settings .............. 62 Evaluator ................................ 49 Compiler section ........................... 62 Inspector ................................ 49 Code Generation Options ................. 63 Thread .................................. 49 C++ Options ............................. 65 Memory ................................. 49 Optimizations ........................... 67 Registers ................................ 49 Source Options ........................... 68 Numeric Processor ....................... 49 Messages ................................ 69 Heap .................................... 49 Names .................................. 70 Hide Windows ........................... 49 Make section .............................. 70 Show Windows .......................... 49 Target section .............................. 71 Tools menu ................................ 50 Linker section . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 View Transcript .......................... 50 Link Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 Previous Error ........................... 50 Link Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 Next Error ............................... 50 Link Warnings ........................... 74 Remove Messages ........................ 50 Librarian section ........................... 74 Transfer items ............................ 50 Debugger Options section ................... 75 Project menu ............................... 51 Debugger Options ........................ 75 Open Project ............................. 51 Disassembly View Local Options ... : ....... 77 Close Project ............................. 51 Variables View Local Options .............. 78 View Project ............................. 51 Call Stack View Local Options ............. 79 View Settings ............................ 51 Watch View Local Options ................ 79 Add Item ................................ 51 Evaluator View Local Options ............. 80 Delete Item .............................. 52 Inspector View Local Options .............. 80 Local Options ............................ 52 Memory View Local Options .............. 80 Include Files ............................. 52 Register View Local Options ............... 81 Generate Makefile ........................ 52 File And Numeric View Local Options ...... 82 Save .................................... 53 Directories section . . . . . . . . . . . . . . . . . . . . . . . . . . 82 Window menu ............................. 53 Environment section ........................ 83 Tile ..................................... 53 Preferences .... . . . . . . . . . . . . . . . . . . . . . . . . . . 83 Cascade ................................. 53 Desktop ................................. 85 Appendix A The optimizer 129 Editor ................................... 85 What is optimization? ...................... 129 Fonts .................................... 87 When should you use the optimizer? .... 129 Syntax Hilite ............................. 88 Optimization options ...................... 129 Transfer section ............................ 89 A closer look at the Borland C++ optimizer. 131 Global register allocation ............... 131 Chapter 5 Managing multi-file projects 93 Globaloptimizations .................. 131 Sampling the Project Manager ................ 94 Common sub expression elimination ..... 131 Error tracking .............................. 96 Loop invariant code motion ............ 132 Stopping a make ......................... 97 Copy propagation ..................... 132 Syntax errors in multiple source files ........ 97 Induction variable analysis and strength Saving or deleting messages ............... 98 reduction ............................. 133 Autodependency checking ................. 98 Linear function test replacement ........ 133 Using different file translators ................ 99 Loop compaction ...................... 134 Overriding libraries ........................ 101 Dead storage elimination ............... 135 More Project Manager features .............. 101 Pointer aliasing ....................... 135 Looking at files in a project ............... 103 Code size versus speed optimizations .... 136 Chapter 6 Command-line compiler 105 Intrinsic function inlining .............. 136 Running BCC ........................... 105 Register parameter passing . . . . . . . . . . . . . 138 Using the options ........................ 105 Parameter rules ....................... 138 Option precedence rules ................ 106 Floating-point registers ................ 138 Syntax and file names .................... 109 Function naming ...................... 139 Response files ........................... 110 Appendix B Editor reference 141 Configuration files ....................... 110 Block commands ........................ 144 Option precedence rules ................ 111 Other editing commands ................. 145 Compiler options .......................... 111 Macro definitions ........................ 112 Appendix C Precompiled headers 147 Code-generation options ................. 113 How they work ........................... 147 The -v and -vi options ................. 115 Drawbacks ............................. 148 Optimization options .................... 116 Using precompiled headers ................. 148 Source code options ...................... 116 Setting file names ....................... 148 Error-reporting options .................. 117 Establishing identity ..................... 148 Segment-naming control ................. 119 Optimizing precompiled headers . . . . . . . . . . 149 Compilation control options .............. 120 Appendix 0 Using the Browser 151 C++ virtual tables ....................... 121 Browsing through your code ................ 151 C++ member pointers .................... 122 Browsing through objects ................ 153 Template generation options .............. 123 Filters ................................ 154 Exception handling/RTTI ................ 124 Viewing declarations of listed symbols . . . 155 Linker options ............................ 124 Environment options ....................... 125 Browsing through global symbols ......... 155 Browsing symbols in your code ........... 155 Include file and library directories ......... 125 File-search algorithms .................... 126 Index 157 An annotated example ................. 127 iii Tables 2.1 General hot keys ........................ 22 A.1 Optimization options summary ......... 130 2.2 Menu hot keys .......................... 22 A.2 Parameter types and possible 2.3 Editing hot keys ........................ 23 registers used ......................... 138 2.4 Online Help hot keys .................... 23 B.1 Editing commands ..................... 141 2.5 Debugging/Running hot keys ............ 23 B.2 Block commands in depth .............. 144 2.6 Manipulating windows .................. 25 B.3 Borland-style block commands .... . . . . . . 145 3.1 Search-string wildcards .................. 42 B.4 Other editor commands in depth ........ 145 6.1 Command-line options summary ........ 106 D.1 Letter symbols in the Browser ........... 154 iv Figures D.l Buttons on the Browser SpeedBar ........ 152 D.3 Viewing the details of an object ......... 154 D.2 Viewing the object hierarchy of an application ........................... 153 v vi Introduction Borland C++ is a professional optimizing compiler for C++ and C develop ers. It's powerful, fast, and efficient. With Borland C++, you can create practically any OS/2 or Presentation Manager application. Because C++ is an object-oriented programming (OOP) language, it gives you the advantages of advanced design methodology and labor-saving features. It's the next step in the natural evolution of C. And because it's portable, you can easily transfer application programs written in C++ from one system to another. You can use C++ for almost any programming task on any platform. What's in Borland C++ Chapter 1 tells you Borland C++ includes the latest features programmers have asked for: how to install Borland C++. This .. C and C++: Borland C++ offers you the full power of C and C++ pro- Introduction tells you gramming, with a complete implementation of the AT&T v. 3.0 , where you can find specification as well as a 100% ANSI C compiler. Borland C++ for OS/2 out more about each feature. also provides a number of useful C++ class libraries, plus the a complete implementation of templates and exception handling, which allow efficient collection classes to be built using parameterized types. • Global optimization: a full suite of state-of-the-art optimizations gives you complete control over code generation, so you can program in the style you find most convenient, yet still produce small, fast, highly efficient code. • Faster compilation speed: Precompiled headers significantly shorten recompilation time. Optimizations are also performed at high speed, so you don't have to wait for high quality code. • Programmer's Platform: Borland C++ for OS/2 comes with an improved version of the Programmer's Platform, Borland's open-architecture integrated development environment (IDE) that gives you access to a full range of programming tools and utilities, including • A multi-file editor featuring an industry-standard Common User Access (CUA) interface . • Turbo Editor Macro Language (TEML) and the Turbo Editor Macro Compiler (TEMC), which provide the ability to create and use a customized editor interface. Introduction