Borland_C++_Version_4.0_Users_Guide_Oct93 Borland C Version 4.0 Users Guide Oct93
Borland_C++_Version_4.0_Users_Guide_Oct93 Borland_C++_Version_4.0_Users_Guide_Oct93
User Manual: Borland_C++_Version_4.0_Users_Guide_Oct93
Open the PDF directly: View PDF .
Page Count: 462
or an
++
User's Guide
Borland® C++
Version 4.0
Redistributable files
You can redistribute the following files in accordance with the No Nonsense License
Statement:
•
•
•
•
•
•
•
BC40RTL.DLL
BIDS40.DLL
BIDS40F.DLL
BIVBX1 O.DLL
BW320007.DLL
BW320009.DLL
BW32000C.DLL
•
•
•
•
BWCC.DLL
BWCCOO07.DLL
BWCCOO09.DLL
BWCCOOOC.DLL
• BWCC32.DLL
• COMPRESS.EXE .
• CTL3D.DLL
• CTL3D32.DLL
•
•
•
•
CW32.DLL
CW32MT.DLL
CX32.DLL
CX32MT.DLL
• DIB.DRV
.• GAUGEVBX
• LOCALEBLL
• MARS.DLL
• MARS.MOB
• MSMOUSEDRV
.OWL200.DLL
• OWL200F.DLL
• PICT.VBX
• REGLOAD.EXE
• STRESS.DLL
• SWITCH.VBX
• TOOLHELP.DLL
• VGAP.DRV
• YESMOUSE.DRV
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,1993 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 95067-3249 .
PRINTED IN THE UNITED STATES OF AMERICA
1EOR1093
9394959697-9876543
W1
Contents
Introduction
1
What's new in Borland c++ ................... 1
Manual conventions ......................... 2
Contacting Borland .......................... 2
Part I Using Borland C++ for Windows
Chapter 1 Getting started
7
Installing Borland C++ ....................... 7
Hardware and software requirements ........ 7
Installation steps .......................... 8
Starting Borland C++ ..................... 10
Getting Help ............................. 11
Configuring the IDE ........................ 11
Changing the SpeedBars ................... 12
Setting IDE preferences ................... 13
Saving your IDE settings ...... : ........... 13
Using the Editor ............................ 14
Configuring the IDE editor ................ 14
Syntax highlighting ....................... 14
Working with the Message window ........... 15
Browsing through your code ................. 16
Browsing through objects (class overview) ... 17
Filters ................................. 17
Viewing declarations of listed symbols .... 18
Browsing through global symbols .......... 18
Using regular expressions in the browser .. 19
Browsing symbols in your code ............ 20
Using command-line tools ................... 20
DPMI and the command-line tools .......... 20
Memory and MAKESWAP.EXE ............ 21
The run-time manager and tools ............ 21
Controlling the memory RTM uses ....... 21
Running other programs from the IDE ........ 22
Chapter 2 Using the project manager
25
What is project management? ................ 25
Creating a project ........................... 26
Creating a multiple-target project ........... 28
Converting old projects ................... 29
Converting projects to makefiles ......... " . 29
Changing the Project View .......... , ...... 29
Building a project ..................... : ..... 30
Building part of a project .................. 30
Editing the projecttree ...................... 31
Editing target attributes with TargetExpert " 32
Editing node attributes .................... 32
Adding and deleting a node ............... 33
Adding and deleting targets ............... 33
Moving nodes and targets ................. 34
Copying nodes ............................ 34
Using Source Pools ......................... 35
Setting project options ...................... 36
Local Override ........................... 36
Using Style Sheets ... , .................... 37
Attaching a Style Sheet to a node ......... 37
Creating a Style Sheet ................... 38
Editing Sty Ie Sheets . . . . . . . . . . . . . . . . . . . . . 38
Sharing Style Sheets .................... 39
Viewing options in a project ............... 40
Translators ................................ 40
Installing a translator ..................... 41
Using Special on the SpeedMenu ........... 42
Installing viewers and tools . . . . . . . . . . . . . . . . 42
Chapter 3 Compiling
43
Compiling in the IDE ....................... 43
Using IDE compiler options ............... 44
Using the command-line compilers ........... 44
Configuration files ........................ 45
Response files . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
Option precedence rules .................. 46
Compiler options reference " ................ 46
Directories ................................ 55
File-search algorithms .................... 56
Compiler I Defines .......................... 56
Compiler I Code-generation .................. 57
Compiler I Floating Point .................... 58
C~mpiler I Compiler Output ................. 59
Compiler I Source ........................... 59
Compiler I Debugging ....................... 60
Compiler I Precompiled headers ............ '.. 61
16-bit Compiler I Processor .................. 61
16-bit Compiler I Calling Convention .......... 62
16-bit Compiler I Memory Model ............. 62
16-bit Compiler I Segment Names Data ........ 65
16-bit Compiler I Segment Names Far Data .... 65
16-bit Compiler I Segment Names Code ....... 66
16-bit Compiler I Entry /Exit Code . ~ .......... 66
32-bit Compiler I Processor ................... 68
32-bit Compiler I Calling Convention .......... 68
C++ Options I Member Pointer ............. ;. 69
C++ Options I C++ Compatibility ............. 69
C++ Options I Virtual Tables ................. 70
C++ Options I Templates .................... 71
C++ Options I Exception handling/RTTI ....... 71
Optimizations ............. '................. 72
Optimizations I Specific ...................... 72
Optimizations I Size ......................... 73
Optimizations i Speed ....................... 74
Messages .................................. 76
Messages I Portability ....................... 77
Messages I ANSI Violations .................. 77
Messages I Obsolete C++ ..................... 78
Messages I Potential C++ Errors .............. 78
Messages I Inefficient C++ Coding ............ 78
Messages I Potential errors ....... '............ 78
Messages I Inefficient Coding ................. 79
Messages I General ........... ,............... 79
Make ..................................... 79
Command-line options ...................... 79
Chapter 4 Building applications with AppExpert 83
AppExpert basics ........................... 83
Creating an application with AppExpert ....... 84
Default AppExpert applications ............ 85
Application options ......................... 85
Application I Basic Options ................ 86
Application I Advanced Options ............ 86
Application I Code Gen Control ............ 87
Application I Admin Options ............... 87
Main Window options ...................... 88
Main Window I Basic Options .............. 88
Main Window I SDI Client ................. 89
Main Window I MDI Client ................ 90
MDI Child/View options .................... 90
MDI Child/View I Basic Options ...... ~ .... 90
Chapter 5 Using Class Expert
93
Starting ClassExpert ........................ 93
Class Expert basics ........................ 93
Classes pane ........................... 94
Events pane ............................ 94
Edit pane ................. ; ............ 94
Adding a class ........................... 94
Creating document types .................. 95
Adding and deleting event handlers ........ 96
Adding and deleting instance variables ...... 97
Jumping to class source code ............... 98
Using Resource Workshop with ClassExpert ... 98
Running Resource Workshop from the IDE .. 99
Using Rescan .............................. 99
Deleting a class ......................... 100
Moving a class .......................... 100
Renaming an AppExpert element ......... 100
Importing a class ........................ 101
Rebuilding the .APX database file ......... 101
Chapter 6 Using the integrated debugger
103
Types of bugs ............................. 103
Compile-time errors ..................... 103
Run-time errors ......................... 104
Logic errors ............................ 104
Generating debugging information .......... 105
Specifying program arguments ............. 105
Controlling program execution .............. 105
Watching program output ................ 106
Stepping through code ................... 106
Tracing into code ........................ 107.
Stepping and tracing class member
functions ............................. 107
Stepping and tracing external code ...... 108
Stepping over large sections of code ........ 108
Running to a specific location ........... 108
Locating a function .................... 108
Returning to the execution point ........ 108
Navigating backward .................. 108
Stopping the program ................... 109
Starting over . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109
Examining values ......................... 109
What's an expression? .................... 110
Watching expressions .................... 110
Adding a watch ....................... 110
Formatting watch expressions .......... 111
Disabling a watch ..................... 112
Deleting a watch ...................... 112
Editing a watch ....................... 112
Evaluating and modifying expressions ..... 112
Evaluating expressions ................. 112
Modifying variables ......... ; ......... 113
Inspecting data elements ................. 114
Examining register values ................ 115
Using breakpoints ......................... 116
Setting breakpoints .............. , ....... 116
Working with breakpoints ................ 116
Deleting breakpoints ................... 117
Disabling and enabling breakpoints ..... 117
TLINK.CFG ............................
Response files ...........................
Using TLINK with BCC.EXE ..............
Linking libraries ........................
TLINK options ............................
Module-definition file reference .............
CODE statement ........................
DATA statement ........................
DESCRIPTION statement ................
EXETYPE statement .....................
EXPORTS statement .....................
Chapter 7 WinSight
123
IMPORTS statement .....................
Getting started ............................ 123
LIBRARY statement .....................
Starting and stopping screen updates ...... 123
NAME statement ........................
Turning off message tracing ............. 124
SEGMENTS statement ...................
Choosing a view ........................... 124 . STACKSIZE statement ...................
Class List ................................. 124
STUB statement ................ ~ ........
Using the Class List view ................. 125
Module-definition file defaults .............
Spying on classes ........................ 125
Window Tree ............................. 125 Chapter 10 Using resource tools
Finding a window ....................... 126 BRCC.EXE: The resource compiler ...........
Leaving Find Window mode ............ 127 RLINK: the resource linker .................
Spying on windows ...................... 127 BRC.EXE: the resource shell ................
Choosing messages to trace ................. 127
Using the Message Trace view ............ 127 Chapter 11 Using libraries
Other tracing options .................. 128 Using IMPLIB: The import librarian .........
Using IMPDEF: The module-definition file
Chapter 8 WinSpector
133 manager .................................
Classes in a DLL ........................
Using WinSpector ......................... 133
Functions in a DLL ......................
Configuring WINSPCTR LOG: ............ 134
WINSPCTRLOG reference ............... 135 Using TLIB: the Turbo Librarian .............
Why use object module libraries? ..........
Disassembly section ................... 136
The TLIB command line ..................
Stack Trace section ..................... 136
Using response files ...................
Register section ....................... 137
Message Queue section ................. 137
Using case-sensitive symbols: The IC
option ...............................
Tasks section .......................... 138
Creating an extended dictionary: The IE
Modules section ....................... 138
option ...............................
USER and GDI heap section ............ 139
Setting the page size: The IP option .....
System Information section ............. 139
Processing WinSpector data ................. 139
Removing comment records: The 10
option ......, .............. : ..........
DFA output ............................. 140
The operation list ......................
Using DFA with WINSPCTRLOG ......... 140
Examples ...............................
Using DFA with WINSPCTRBIN .......... 140
Other WinSpector tools ..................... 141
Chapter 12 Using MAKE
Using EXEMAP.EXE ..................... 141
MAKE
basics .................. '...........
Using TMAPSYM.EXE ................... 142
BUILTINS.MAK
........................
Using BUILDSYM.EXE ................... 142
Using TOUCH.EXE ......................
Chapter 9 Using the linker: TUNK
143
MAKE options ..........................
Setting options on as defaults ...........
TLINK basid; ............................. 143
Viewing and editing code at a breakpoint. 117
Resetting invalid breakpoints ........... 118
Changing breakpoint properties ......... 118
Logging expressions ................... 119
Customizing breakpoints and the execution
point ............................' ....... 120
Catching general protection faults ........... 120
Using the Event Log window ............... 120
Debugging dynamic-link libraries ........... 121
Debugging in soft and hard mode ........... 122
iii
144
145
146
146
147
154
154
155
155
155
156
157
157
158
158
159
159
159
161
162
163
164
167
167
168
169
169
170
170
171
171
172
172
172
173
173
174
175
175
176
177
177
178
Compatibility with Microsoft's NMAKE .. 178
Show Identifiers ....................... 204
Using makefiles ........................... 179
Show Resources ....................... 204
Symbolic targets ......................... 179
Show Items . ; ......................... 204
Show Unused Types ................... 204
Rules for symbolic targets .............. 180
Explicit and implicit rules .................. 180 ,
Selecting a resource . . . . . . . . .. . . . . . . . . . . . . 204
Explicit rule syntax ...................... 180 Working with resources .................... 204
Single targets with multiple rules ........ 181
Loading a resource ...................... 204
Implicit rule syntax ...................... 182
Resource editors ...................... 205
Explicit rules with implicit commands ... 182
The internal text editor ...... , .......... 205
Commands syntax ..... " ................ 183
Adding a resource .. ~ .................... 205
Command prefixes .................... 183
Adding an embedded resource .......... 206
Using @ .' . . . • . . . . . . . . . . . . . . . . . • . . . . . . • 183
Adding a linked resource ............... 206
Using -num and - ............... ; ..... 183
Moving a resource ....................... 207
Using & .............................. 184 , Copying resources between projects ....... 207
Command operators ................... 184
Deleting a resource ...................... 208
Debugging with temporary files ......... 184
Renaming a resource .................... 208
Using MAKE macros ....................... 185
Specifying resource memory options ....... 209
Defining macros ......................... 185 Using identifiers .......................... 210
Using a macro ........................... 186
Components of resource identifiers ........ 210
String substitutions in macros ............. 186
Identifier files ........................... 211
"Creating identifier files ................. 211
Default MAKE macros ................... 186
Modifying default macros ................ 187
C header files ......................... 211
Using MAKE directives .................... 188
Automatic identifier management ......... 212
.autodepend ..... '....................... 189
Working without an identifier file ......... 213
!error .................................. 189
Adding identifiers ....................... 213
Summing up error-checking controls ..... 189
By renaming resources ................. 213
!if and other conditional directives ......... 190
By using the Identifiers dialog box ....... 214
!include ................................ 191
Editing identifiers ....................... 214
!message ................. : ............. 191
Deleting identifiers ...................... 214
.path.ext ................................ 192
Listing identifiers ....................... 215
.precious ....... ',' ............. '......... 192
Starting a resource editor ................. 215
.suffixes ................................ 192 Setting preferences ........................ 216
!undef .............................. '.... 193
Undo Levels ............................ 216
Using macros in directives .............. , . 193
Text Editor ............................. 216
Nun macros ............................ 193
'Multi-Save ............................. 216
Target Windows Version ................. 217
Part" Using Resource Workshop
Working with binary files .................... 217
Chapter 13 Resource Workshop basics
197 Creating 32-bit resources ................... 218
Understanding Windows resources ., ......... 197 Chapter 15 Creating dialog boxes
221
Types of resource files ...................... 199 Starting the Dialog editor ................ : . ; 221
Bitmapped resource files ................. 200
Creating a new dialog box ................ 221
I
Editing an existing dialog box ............. 222
Using the Dialog editor .................... 222
Selecting a dialog box . . . . . . . . . . . . . . . . . . . . 223
Setting dialog box attributes .............. 223
Adding a caption ...................... 223
Choosing a frame style ................. 224
Choosing a dialog style ................ 224
Chapter 14 Working with projects, resources, and
identifiers
201
Creating a new project ..................... 201
Opening an existing project ................. 202
Using the Project window .................. 202
, Embedded and linked resources ........... 203
Displaying the Project window ............ 203
iv
Changing fonts ........................ 225
Including a menu ...................... 225
Assigning a custom class to a dialog box .. 226
Setting dialog box position ................ 226
Working with controls ................... 226
Families of controls .................... 226
Tools palette .......................... 227
Selecting controls ...................... 229
Adding controls ....................... 231
Adding multiple copies of a control ...... 231
Control'properties (.VBX controls) ....... 232
Moving controls ....................... 232
Resizing controls ...................... 232
Locating and sizing controls at the
same time ............................ 232
Aligning controls with a grid ............ 233
Editing controls ......... ' .............. 233
Adding captions to controls ............. 235
Changing a control's class ............... 235
Specifying controls as tab stops .......... 235
Grouping related controls .............. 236
Reordering controls (tab order) .......... 236
Aligning, resizing, and arranging controls .. 237
Aligning multiple controls .............. 237
Placing controls in columns and rows .... 239
Resizing multiple controls .............. 240
Single-control sizing options ............ 241
Button controls .......................... 241
Push button Control ID values .......... 242
Scroll bar controls ....................... 243
List box controls ......................... 244
Edit text controls ........................ 246
Static controls ........................... 248
Iconic static controls ................... 249
Combo box controls ..................... 250
Custom controls ......................... 251
Creating your own custom controls ...... 252
Installing a control library (.DLL or .VBX) .252
, Displaying custom cont~ols ............. 252
Adding a custom control ............... 252
Testing a dialog box ....................... 253
Viewing two dialog boxes .................. 253
Customizing the Dialog editor' .............. 254
Chapter 16 Creating menus
257
Menu terminology ......................... 257
Starting the Menu editor ................... 258
Creating a new menu .................... 258
Editing an existing menu ................. 258
Menu editor screen ........................
Attribute pane ..........................
Test Menu pane ............ " ...........
Outline pane ............................
Editing menus ............................
Adding new statements ..................
Adding menu items and separators ........
Editing menu items ............. , ........
Using the Attribute pane ...............
Entering item text .....................
Entering item IDs .....................
Moving and copying statements ...........
Deleting menu statements ................
Creating floating menus ..................
Testing menus ....... : ....................
Editing menu resource scripts ...............
Sample menu .............................
Creating the sample menu ................
Adding commands to the menu .........
Adding commands to the Arrange
List menu ............................
Testing the menu ..... '" ..............
259
259
259
259
260
260
261
261
262
264
264
264
265
265
266
267
268
268
269
Chapter 17 Creating accelerators
271
Accelerator table key combinations ..........
ASCII keys .............................
Virtual keys .. ; .........................
Starting the Accelerator editor ..............
Creating a new accelerator table ...........
Editing an existing accelerator table ........
Running the Menu editor at the same time ..
Using the Accelerator editor ................
Outline pane ............................
Attribute pane ..........................
Editing an accelerator table .................
Adding an accelerator key ................
Selecting an accelerator key ...............
Using the Attribute pane .................
Setting the command value .............
Specifying the accelerator key ...........
Flash feature ..........................
Checking for duplicate key combinations .....
Creating a sample accelerator table ..........
271
272
272
272
272
273
273
273
273
274
275
275
275
275
276
276
277
277
Chapter 18 Creating a string table
281
281
281
282
282
Starting the String editor ...................
To create a new string table ...............
To edit an existing string table ............
Working with string tables ..................
v
270
270
277
Windows and strings .................... 283
Entering a new string .................... 283
Editing existing strings ........... _........ 284
Changing a string ..................... 284
Editing the resource script of a string table .. 285
Changing the string .................... 285
Creating a sample string table ............... 285
Save with default device colors ......... 308
Chapter 20 Creating icons
309
Creating a new icon ....................... 309
Adding an icon to a project file ............ 309
Creating a standalone icon file ............ 310
'Binary format option .................. 310
Icon project file ....................... 311
Editing icons .............................. 311
Viewing other resolutions ................ 311
Using transparent and inverted color areas . 311
Adding an image to an icon resource ........ 312
Changing an icon's attributes ............... 313
Displaying device information ............ 313
Creating a sample icon ..................... 314
Drawing the calculator ................... 314
Adding a three-dimensional effect ........ ; 315
Drawing the ledger page ................. 316
Chapter 19 Using the Bitmap editor
289
Starting the Bitmap editor .................. 289
Pixels, foreground and background colors .... 289
Using the Tools palette ..................... 290
Pick Rectangle tool ...................... 292
Scissors tool ............................ 292
Zoom tool ..................... ~ ........ 292
Eraser tool .............................. 293
Pen tool ................................ 293
Paintbrush tool .......................... 293
Airbrush tool ........................... 294
Paint Can tool ........................... 294
Line tool ................................ 295
Text tool ................................ 295
Painting empty frames ................... 296
Painting filled frames ............. , ...... 296
Hand tool .............................. 297
Style selections .......................... 297
Using the two window panes ............... 297
Reading the status line ..................... 298
Working with colors ....................... 298
Choosing the number of colors for a
resource ................ ,................ 299
Using foreground and background colors ... 299
Transparent and inverted color areas ....... 300
Setting transparent and inverted colors ... 300
Hiding and showing the Colors palette ..... 301
Customizing colors ........................ 301
Editing colors in the Colors palette ......... 302
Palette index ........ ,.................. 302
Editing a color ........................ 302
Adding text to a bitmap .................... 303
Aligning text ............................ 303
Choosing fonts, size, and text style ......... 304
Choosing brush shapes ..................... 304
Choosing paint patterns .................... 305
Choosing a line style ....................... 306
Aligning a selected area .................... 306
Resizing a selected area .................... 307
Setting global Bitmap editor options ......... 307
Draw on both images .................. 308
Chapter 21 Creating cursors
Creating a new cursor ......................
Adding a cursor to a project file ...........
Creating a standalone cursor file ..........
Binary format option ..................
Cursor project file .....................
Editing cursors ............................
Colors palette for cursors .................
Working with transparent and
inverted areas ...........................
Setting the cursor's hot spot ...............
Chapter 22 Creating fonts
Font types ................................
Why put bitmaps in a font? ...............
Creating a new font resource ...............
Adding a font to a project file .............
Creating a standalone font file ............
Binary format option ..................
Font project file .......................
Editing a font resource .....................
Defining and adding characters for a font ..
Defining the font size ..................
Setting the number of characters ........
Mapping the character set ..............
Creating variable-width fonts .............
, Setting the width of a character or image.
Defining a header for a font resource .......
Changing size and attributes ..............
Using your fonts in your applications ........
vi
319
319
319
320
320
321
321
321
321
321
323
323
324
324
324
325
325
325
326
326
326
327
327
328
328
329
330
330
Chapter 23 Creating user-defined resources
331
Creating a resource type .................... 332
Adding user-defined resources .............. 332
Editing user-defined resources .............. 333
Embedding resource data in the project file .334
Entering data in the resource script ........ 334
Handling data stored in a separate file ..... 335
Using the RCDATA resource type ............ 335
Appendix A Error messages
337
Message classes ........................... 337
Fatal errors ............................. 337
Errors .................................. 338
Warnings ............................. '.. 338
Help compiler messages .................... 338
Message listings ........................... 339
Message explanations ...................... 339
Borland Button Style dialog box .........
Borland Radio Button Style dialog box ...
Borland Check Box Style dialog box .....
Borland Shade Style dialog box .........
Borland Static Text Style dialog box ......
Modifying existing applications for BWCC ...
Loading BWCC .........................
Using BWCC in C and C++ programs ....
Tips on editing resources .. '. ~ .............
398
400
400
400
400
401
401
401
402
Appendix C Precompiled headers
403
403
404
404
4:04
405
405
How they work ...........................
Drawbacks .............................
Using precompiled headers .................
Setting file names .......................
Establishing identity .....................
Optimizing precompiled headers ..........
Appendix 0 Using EasyWin
407
ConsoleD OS to Windows made easy ......... 407
_InitEasyWin() ........................... 407
Added functions ........................ 408
Appendix B Borland Windows Custom Controls 395
Using the Borland custom dialog class ....... 395
Using Borland controls ..................... 396
Button and check box enchancements ...... 397
Using the BWCC style dialog boxes ........ 398
Index
vii
409
Tables
1.1 Letter symbols in the Browser ............. 19 11.3 TLIB action symbols ................... 174
1.2 Browser search expressions .............. 19 12.1 MAKE options ........................ 177
12.2 Command prefixes .................... 183
1.3 Environment variables for RTM's memory
allocation .............................. 22 12.3 Command operators .................. 184
3.1 Options summary ....................... 47 12.4 Command line vs. makefile macros ..... 186
4.1 Client/view class with Document/view ... 89 12.5 Default macros ......................., 187
12.6, Other default macros .................. 187
4.2 MDI client/view class with
Document/view ........................ 91 12.7 File-name macro modifiers ............. 187
6.1 Format specifiers for debugger expressions .113 12.8 MAKE directives ..................... 188
6.2 CPU flags in the Register window ........ 115 _ 12.9 Conditional operators ................. 191
6.3 Event Log window SpeedMenus ......... 121 14.1 Resource memory options .............. 209
7.1 Mouse messages ....................... 129 14.2 Identifier prefixes ..................... 212
7.2 Window messages ..................... 129 15.1 Common options in Style dialog boxes ... 234
7.3 Input messages ........................ 129 15.2 Control attributes ..................... 234
7.4 System messages ....................... 130 15.3 Alignment options .................... 237
7.5 Initialization messages .................. 130 15.4 Size options .......................... 240
7.6 Clipboard messages ................ ~ ... 130 15.5 Button types ......................... 242
7.7 DDE messages ......................... 130 15.6 Predefined Windows button controls .... 243
7.8 Nonclient messages ........... ,......... 130 15.7 Alignment options .................... 244
7.9 Print messages ............... ' .......... 130 15.8 Owner Drawing options ............... 244
7.10 Control messages ..................... 131 15.9 List Box options ...................... 245
7.11 Pen messages ......................... 132 15.10 Edit Text Style dialog box options ...... 246
7.12 Multimedia messages .................. 132 15.11 Windows 3.1 styles ................... 247
7.13 Other messages ....................... 132 15.12 Control Type options ................. 248
7.14 Messages not documented by Microsoft .. 132 15.13 Combo box Type options ............. 25U
8.1 Exception types ............ : ........... 135 15.14 Owner Drawing options .............. 250
8.2 DFA options ........................... 141 15.15 Combo box attributes ......... ~ ....... 251
9.1 Borland 16-bit libraries and startup files ... 146 16.1 View menu selections ................. 259
9.2 Borland 32-bit libraries and startup files, .. 147 16.2 Menu editor Attribute pane selections ... 262
9.3 TLINK options ........................ 147 17.1 Attribute pane selections ............... 274
9.4 TLlNK32 warnings ..................... 153 19.1 Zoom commands ..................... 292
10.1 BRCC (Borland resource compiler) ...... 162 22.1 Font size options ...................... 327
10.2 RLINK switches ...................... 163 22.2 Character options ..................... 328
10.3 BRC switches ......................... 164 22.3 Font header options ................... 329
11.1 IMPLIB options ....................... 168 B.1 Predefined BWCC button controls ....... 399
11.2 TLIB options ......................... 171 B.2 Bitmap offsets ......................... 399
viii
Figures
1.1 Elements ofthe IDE ..................... 10
1.2 Viewing classes in an application ......... 17
1.3 Symbol declaration window .............. 18
1.4 Viewing globals ......................... 18
2.1 The project tree ......................... 26
5.1 The ClassExpert window ................. 93
6.1 The Watch window ..................... 110
6.2 The Watch Properties dialog box ......... 111
6.3 The Breakpoint window ................ 116
6.4 The Breakpoint Properties dialog box ..... 117
14.1 Project window showing respurces by file .203
15.1 A typical dialog box ................... 221
15.2 Dialog editor with empty dialog box .... 222
15.3 Tools palette .......................... 228
15.4 Dialog box coordinates ................ 233
15.5 Control order options .................. 239
15.6 Size Controls dialog box ............... 240
15.7 Edit text control ...................... 246
15.8 Combo box from Open File dialog box ... 250
16.1 Sample menu ......................... 268
18.1 String editor with string table entries .... 282
18.2 String editor with four strings defined ... 287
19.1 Bitmap editor Tools palette ............. 291
19.2 16-color Colors palette ................. 299
19.3 16-color palette index .................. 302
19.4 Aligning text . . . . . . . . . . . . . . . . . . . . . . . . . 304
20.1 Icon window ......................... 312
20.2 Calculator before adding drop shading .. 315
20.3 Calculator with shading ............... 316
20.4 Finished Home Budget icon ............ 317
B.1 Dialog box with Borland controls ........ 396
ix
x
Introduction
See the Roadmap for
information on the
manuals and online
Help included with
Borland C++.
Borland C++ is a powerful professional tool for creating and maintaining
DOS, Windows, Win32s, and Windows NT applications using the C and
C++ languages. Part 1 of this manual introduces you to the Integrated
Development Environment (IDE) and the command-line tools needed to
create applications. Part 2 teaches you how to use Resource Workshop to
build Windows resources for your applications.
Whats new in Borland C++
Borland C++ 4.0 has many more features than previous releases. The
following is a brief list of major additions and changes:
• The 32-bit compiler and tools generate 32-bit targets for Win32s and
Windows NT .
• You can generate DOS programs from the Windows IDE.
• The IDE has a graphical integrated debugger for debugging 16-bit
Windows applications.
• The IDE has an enhanced editor that lets you record keystroke macros,
work in multiple panes in one editor window, and search for text using
regular expressions. You can configure the editor to use Brief or Epsilon
keystrokes or you can create your own keystrokes.
• The right mouse button brings up SpeedMenus that list commands
specific to the object you click. For example, some common editing
commands are on the SpeedMenu of all editor windows. (To access old
functions of the right mouse button, press Ctrl+click right mouse button.)
• The IDE has a new multiple-target project manager that visually shows
file dependencies and lets you manage more than one program.
• The IDE has a new multiple-window ObjectBrowser that displays class
relationships.
• Using AppExpert you can quickly generate ObjectWindows 2.0 Windows
programs. ClassExpert helps you modify and organize your AppExpert
application.
Introduction
Manual conventions
This manual uses special fonts and icons as follows:
Monospaced type
. This
font represents text that you type or onscreen text.
Italics
Italics are used to emphasize certain words and indicate variable names
(identifiers), C++ function names, class names, and structure names.
Bold
Reserved keywC?rds words, format specifiers, and command-line options
appear bold.
Keycap
ALL CAPS
Menu IChoice
This font represents a particular key you should press-for example, "Press
Del to erase the character."
All caps are used to represent disk directories, file names, and application
names.
Rather than use the phrase"choose the Save command from the File
menu," this manual uses the convention"choose File ISave".
16-bit Windows
32-bit Windows
Contacting Borland
Borland offers a variety of services to help you with your questions. Be sure
to send in the registration card: registered owners are entitled to receive
technical support and information on upgrades and supplementary
products. North American customers ca~ register by phone 24 hours a day
by calling 1-800-845-0147. Borland provides the following convenient
sources of technical information.
Service
How to contact
Available
Cost
Description
Tech Fax
1-800-822-4269
(voice)
24 hours daily
Free
Sends technical information to your fax
machine. You can request up to 3
documents per call. Requires a TouchTone phone.
Automated support
408-431-5250
(modem)
24 hours daily'
The cost of
the phone call
Requires a Touch-Tone phone or
modem.
2
Borland C++ Users Guide
Online Services
Borland Download
BBS
408-431-5096
24 hours daily
The cost of
the phone call
Sends sample files, applications, and
technical information via your modem.
Requires a modem (up to 9600 baud);
no special setup required.
CompuServe online
service
Type GO BORLAND.
Address messages to
Sysop or All.
24 hours daily;
1-working-day
response time.
Your online
charges
Sends answers to technical questions
via your modem. Messages are public
unless sent by CompuServe's private
,mail system.
BIX online
service
Type JOIN BORLAND.
Address messages to
Sysop or All.
24 hours daily;
1-working-day
response time.
Your online
charges
Sends answers to technical questions
via your modem. Messages are public
unless sent by BIX's private mail
system.
GEnie online
service
Type BORLAND.
Address messages to
Sysop or All.
24 hours daily;
1-working-day
response time.
Your online
charges
Sends answers to technical questions
via your modem. Messages are public
unless sent by GEnie's private mail
system.
For additional details on these and other Borland services, please refer to
the Borland Support and Services Guide that was included with your product.
Introduction
3
4
Borland C++ Users Guide
p
A
R
T
Using Borland C++ for Windows
This section of the User's Guide describes how to install and use Borland
C++. It teaches you how to use the components in the Integrated
Development Environment (IDE), including the integrated debugger, the
browser, AppExpert, ClassExpert, and the project manager. It also
documents the command-lines tools, including the compiler, linker,
librarian, and MAKE. Borland C++,
• Integrates development of DOS, Windows, Win32s, and Windows NT
applications. You can build more than one application type from a single
project file.
• Creates ObjectWindows applications quickly and easily using
AppExpert. After you create an application, ClassExpert helps you
maintain that application by tracking classes and events and works with
Resource Workshop to manage the resources you create and use in your
application.
• Helps you debug and browse your applications without having to use a
separa te debugger.
• Contains a customizable editor. You can use the keyboard shortcuts
provided with Borland C++, or you can customize your own.
This section also describes two Windows programs that help you debug
your applications: WinSight and WinSpector.
There are two online files for Borland C++ that contain additional material
not in the manuals or online Help:
• INSTALL.TXT
• UTILS.TXT
Contains complete installation information for both
floppy and CD ROM installations.
Describes command-line tools and utilitiesnotfoimd
in the manuals or online Help.
c
H
A
p
T
E
R
1
Getting started
Borland C++ is a development package containing Windows tools,
command-line tools, and libraries that help you develop applications for
DOS, Windows, Win32s, and Windows NT. This chapter gives you a .
working description of the Borland C++ product-the IDE, project
manager, AppExpert, tools, and utilities.
Read this chapter to learn how to
•
•
•
•
Install and configure Borland C++
Use the editor
Use syntax highlighting for code
Use the SpeedBar
• Use the Message window
• Browse your code
• Start and use other tools from the
IDE
Other utilities and command-line tools are described briefly in this chapter.
For information on other parts of the Borland C++ product, see the
Roadmap, which points you to topics in the documentation.
Installing Borland C++
Borland C++ contains both DOS and Windows applications. Before you can
install Borland C++, make sure your computer has the minimum hardware
and software requirements.
Hardware and
software
requirements
To use Borland C++, your computer must have:
Chapter 1, Getting started
• DOS version 4.01 or higher
• Windows 3.1 or higher running in 386-enhanced mode
• A hard disk with 40 MB of available disk space for a normal installation
(80MB for a full installation)
,
• A 1.44 floppy drive or CD ROM (for installation)
• At least 4MB of extended memory
• A Windows-compatible mouse
7
Although the following items aren't required, they can greatly increase
your computer's performance:
• 8MB RAM .
• An 80x87 math coprocessor (if you're writing programs that use
floating-point math). Borland C++ emulates a math chip if you don't
have one.
'
Installation steps
If you use a diskcompression utility,
you should read
INSTALL.TXT before
you install Borland
CH.
The Borland C++ install program installs the Borland C++ product (the
IDE, command-line tools, ObjectWindows, and Turbo Debuggers) and it
installs Win32s (Win32s lets you run 32-bit programs under 16-bit
Windows). The installation program works under Windows, Win32s, and
Windows NT; however, not all programs run under Windows NT.
Before you install, make sure your computer meets or exceeds the
hardware and software requirements. If you need more information about
installing Borland C++, read the online file INSTALL.TXT, located on Disk,
1 (this file isn't compressed, so you can view it using any text editor).
The installation instructions for floppy and CD are basically the same, but
you should read the INSTALL.TXT file or the CD liner notes if you're
installing from CD ROM.
To install Borland C++ from floppy disks,
1. Put Disk 1 in your floppy drive (usually A or B).
2. Start Windows and choose File I Run from the Program Manager.
3. Type a: \install (or b: \install if your floppy is in drive B), then press
Enter. The install dialog box appears. At the bottom of this dialog box
you'll see the amount of hard~disk space needed for'a complete install
(Target Requirements). You'll also see the amount of disk space
available on your machine. Make sure you have more than enough
room available for installation before continuing. If your computer uses
disk compression, read the INSTALL.TXT file; you might need more
room than what is listed as available.
4. Click the Customize BC4.0 Installation button if you want to select only
specific files for installation. Another dialog box appears with buttons
and descriptions for areas of the product. Click a button for an area you
want to customize. A dialog box for that area appears where you can
uncheck files you don't want installed (the default installation installs
all files to your machine). Click OK and repeat this process for any areas
you want to customize. Click OK to return to the first install dialog box.
8
Borland C++ User's Guide
5. The install program lists default directories where it will install files.
Type another path only if you want Borland C++ installed to a different
directory .
• Borland C++ destination directory is the main directory under which
all other files are installed (by default the directory is C: \BC4) .
• Borland C++ Configuration File directory is where the installation
program puts the Borland C++ configuration files (usually
C: \BC4 \BIN).
6. By default, the installation program creates a Windows group where it
places all the Borland C++ icons. If you don't want to create a group,
uncheck Create Borland C++ Group.
7., Win32s also installs by default. If you don't want Win32s, uncheck this
option. Win32s is required for running 32-bit applications.
8. Check LAN Windows Configuration only if you're inst~lling on a
machine with LAN Windows.
9. Click Install to begin copying files to your machine. When installation is
complete, you can read the README.TXT file. This file contains lastminute changes to the product, the documentation, and the online Help.
For a description of all the icons that install creates, read the file
INSTALL.TXT located on disk one and C:\BC4.
After you install, make sure your CONFIG.SYS file has FILES and BUFFERS
equal to 40 or more (see your DOS documentation for information on the
CONFIG.SYS file).
The install makes the follow~g changes to existing files on your machine:
• AUTOEXEC.BAT now includes the path to Borland C++ (c: \BC4 \BIN by
default).
• WIN.lNI includes a section [BCW4. 0 INSTALL] that is used by the TASM
install program to locate where Borland C++ is installed on your
machine. Also, inthe [EXTENSIONS] section, the extension IDE is associated
with the IDE (BCW.EXE).
• SYSTEM.lNI includes two device lines:
device: c:\bc4\bin\tddebug.386
device: c:\bc4\bin\windpmi.386
• If you run under Windows NT, NTCMDPROMPT is added to CONFIG.NT.
FILELIST.TXT lists every file that ships with Borland C++. If you need to
free disk space, read this file before. you delete any Borland C++ files.
Chapter 1, Getting started
9
Starting Borland
C++
Borland
c++
To start the IDE, double-click the Borland C++ icon in Windows (shown at
left). The IDE lets you write, edit, compile, link, debug, and manage your
programming projects. The IDE has
• An editor and browser described in this chapter
• A project manager, described in Chapter 2, "Using the project manager"
• A debugger, described in Chapter 6, "Using the integrated debugger"
Figure 1.1 shows some of the components of the IDE.
Figure 1.1
Elements of the IDE
SpeedS
Editor
window
Project
window
-r.f--l~IJeE~aMenu
[.epp) code size=594 lines=274 dala size=99
.. \ .. \ .. \inelude\windows.h [AuloDepend)
.. \ .. \ .. \inelude\sldlib.h [AuloDepend)
" \ .. \ .. \inelude\_dels.h [AuloDepend)
.. \ .. \ .. \inelude\slring.h [AuloDepend)
.. \ .. \ .. \inelude\loeale.h [AuloD epend)
~ whello [.Ie)
&) whello [.del)
Status' bar
The IDE has context-sensitive SpeedMenus that let you modify objects
quickly. To view a SpeedMenu, right-click in a window (the window must
be selected first with the left mouse button) or on an item in a window, or
press Alt+F10 (the SpeedMenu changes depending on what is selected). For
example, to jump to a line in an editor window, right-click in the editor
window, choose Go to line, then type the number for the line you want to
view. The menu item "Go to line" appears only when an editor window is
selected. If you open a SpeedMenu in a project window, you'll view a
completely different set of menu items.
The SpeedBar also changes depending on what window you select. There is
a configurable SpeedBar for the editor, browser, debugger, project manager,
message window, desktop, and ClassExpert (to configure a SpeedBar, see
.1
I
10
Bar/and C++ Users Guide
I
page 12). When you place the mouse pointer over a button on the SpeedBar,
a help line describing the button appears in the status line at the bottom of
the IDE.
Some of the buttons on the SpeedBar are dimmed at times. This means that
the command the button represents isn't available to you in the current
context. For example, if an edit window is open, the Paste Text from
Clipboard button is dimmed if there is no text in the Clipboard.
Getting Help
The Borland C++ Help system gives you online access to detailed
information about Borland C++. You can find most product information in
both the manuals and the online Help. The following topics, however, are
only in online Help:
• IDE menu commands
• Editor KEYMAPPER
• Run-time library example code
• Windows API
To get online Help:
I
~:'
• In the IDE, choose Help from the menu or press F1.
• In dialog boxes, click the Help button or press F1.
• For menu commands, select the menu command and then press F1.
I
Configuring the IDE
You can configure the IDE to do tasks automatically (such as saving a
backup of files in editor windows) or to handle events. This section
describes what you can configure.
The Options I Environment dialog box lets you configure the editor,
browser, debugger, project windows, and other elements of the IDE (these
options are saved in a file called BCCONFIG.BCW).
You can also press +
or - to expand and
collapse the list of
options.
To ope!\ the Environment Options dialog box, choose Options I Environment. The dialog box appears with a, list of topics on the left. Some topics
contain subtopics under them. For example, the Editor topic has subtopics
called Options, File, and Display. When a topic has subtopics that aren't
displayed, the topic contains a + next to the name. When you click a topic's
+ sign, its subtopics appear under it and the + turns to a - (you can then
click the - to collapse the list). Topics that don't contain subtopics appear
with a dot next to their name. When you click a topic, its characteristics
appear to the right in the dialog box.
Chapter 1, Getting started
. 11
Not all Options I Environment topics are discussed in this chapter. See the
online Help (click the Help button in the dialog box) for complete reference
material on all topics and options.
Some topics associated with tasks or parts of the IDE are discussed
elsewhere in this manual (for example, project options are discussed in
Chapter 2). Check the index of this manual for entries on specific topics.
Changing the
SpeedBars
The IDE has SpeedBars for Editor, Browser, Debugger, Project, Message,
Desktop, and ClassExpert windows. When you select one of these types of
windows, the corresponding SpeedBar appears. You can customize each of
the SpeedBars so that they include only the buttons you need.
To add or delete buttons from any of the SpeedBars,
1. Choose Options I Environment from the main menu.
2. Choose the SpeedBar topic on the left. The right side of the dialog box
displays general options for all SpeedBars.
The options here let you choose how you want the -SpeedBar to appear
(top or bottom of the IDE), and how you want it to behave (check Use
flyby,help to view help hints on the status line when you pass the
mouse pointer over a button).
3. Choose Customize, the topic under SpeedBar. The options on the right
display information about the SpeedBars.
, 4. Choose the type of SpeedBar you want to modify (Editor, Browser,
Debugger, Project, Message, Desktop, or ClassExpert) from the Window
drop list.
'
The column on the left (Available Buttons) displays all the available
(unused) buttons with names next to them that describe the button's
function. The column on the right (Active Buttons) displays only the
buttons for the selected SpeedBar.
5. To add a'button, double-click the button icon in the Available Buttons
list, or select it and click the right-pointing arrow. The button moves to
the Active Buttons list.
6. To remove a button from a SpeedBar, double-click the button icon in the
Active Buttons list, or select it and click the left-pointing arrow. The
button moves to the Available Buttons list.
To reorder the button positions for a SpeedBar, use the up and down
arrows. The selected button in the Active Buttons list moves up or down
the list (the top button appears on the far left of the SpeedBar; the last
button in the list appears on the far right).
12
Borland C++ Users Guide
You can also make all SpeedBars identical by selecting a SpeedBar in the
Window list, then pressing the Copy Layout button. A dialog box appears
in which you check all the SpeedBars you want to make identical to the
selected SpeedBar. For example, if you first choose the Editor SpeedBar,
then click Copy Layout, the dialog box appears with Editor dimmed. If you
then check Project and Message, those SpeedBars will be exactly the same
as the Editor SpeedBar.
You can restore any SpeedBar to its original defaults by selecting the
SpeedBar in the Window list then clicking the Restore Layout button.
Separators put space between two buttons. You can add separators to any
SpeedBar by selecting a button from the Active Buttons list then clicking
the Separator button. The separator is added before the selected button.
Setting IDE
preferences
Preferences let you customize what you want saved automatically and how
you want some windows to work.
To set preferences,
1. Choose Options I Environment I Preferences.
2. Check and uncheck the options you want. See the online Help (press the
Help button) for an explanation of each option.
3. Choose OK.
Saving your IDE
settings
The IDE automatically saves information when you exit the IDE, build or
make a project, use a transfer tool, run the integrated debugger, or close,
open, or save a project. You can control the automatic saving by choosing
Preferences from the Environment Options dialog box (choose Options I
Environment from the main menu) and setting options for automatic save.
To save your settings manually,
1. Choose Options I Save.
2. Check Environment to save the settings from the Editor, Syntax
Highlighting, SpeedBar, Browser, and Preferences sections of the
Environment Options dialog box. These settings are saved in a file
called BCCONFIG.BCW.
3. Check Desktop to save information flbout open windows and their
positions. This information is saved to a file called .DSW. If
you don't have a project open, the information is saved to a file called
BCWDEF.DSW.
4. Check Project to save changes to your project (.IDE) file, including build
options and node attributes.
Chapter 1, Getting started
13
Using the Editor
You can open up to
32 editor windows in
the IDE.
Editor windows are where you create and edit your program code. When
you're editing a file, the IDE status bar displays the line number and
character position of the cursor. For example, if the cursor is on the first line
and first character of an editor window, you'll see 1: 1 in the status bar; if
the cursor is on line 68 and character 23, you'll see 68: 23. The IDE status bar
also indicates whether the cursor will overwrite or insert characters (press
Insert to toggle this option) and displays the word Modified if you've made
any changes to the file in the selected edit window.
The editor lets you undo multiple edits by choosing Edit I Undo or pressing
Alt+Backspace. For example, if you delete a line of text, then paste some text,
you can undo these edits: the pasting, which was the last edit, is undone
first, then the deletion. You can set the number of undo actions allowed by
choosing Options I Environment I Editor I Options and setting the Undo
Limit.
Configuring the
IDE editor
The .CKB files also
configure other
windows in the IDE.
See the online Help
for more information.
Syntax
highlighting
You can configure the editor so that it looks and behaves similar to other
editors (like Brief and Epsilon). The IDE editor uses keyboard mapping files
(.CKB) that set the keyboard shortcuts for the editor (these files also change
the keystrokes for other windows).
'
You can use one of the four default .CKE files by choosing Options I
Environment I Editor and clicking a SpeedSetting (Default keymapping,
IDE classic, BRIEF emulation, or Epsilon). To learn how to edit or create
your own .CKB file, see the online Help (search on "Keymapper").
Syntax Highlighting lets you define a color and font attribute (like bold) for
certain elements of code. For example, you could display comments in blue
and strings in red. Syntax Highlighting is on by default. To turn off
highlighting,
1. Choose Options I Environment I Syntax Highlighting.
2. Uncheck Use Syntax Highlighting.
Syntax Highlighting works on files whose extension is listed in the Syntax
Extensions list (.CPP, .C, .H, and .HPP by default). You can add or delete
any extension from this list, but you must separate extensions with
semicolons.
'
The Syntax Highlighting section displays the default color scheme and four
predefined color settings (buttons) you can use.
14
Borland C++ Users Guide
To use a predefined color scheme,
1. Choose Options I Environment ISyntax Highlighting.
2. Choose one of the four color schemes by clicking its button; the sample
code changes to use the color scheme you select. You can use a color
scheme as a starting point for customizing syntax highlighting.
To manually select syntax highlighting colors,
1. Choose Options IEnvironment ISyntax Highlighting ICustomize.
2.
3.
4.
5.
6.
Elements and sample code appear on the top right of the Environment
Options dialog box.
Select an element you want to modify from the list of elements (for
example, Comment), or click the element in the sample code (this selects
the name in the Element list). You might need to scroll the sample code
to view more elements. The sample code uses the font selected in the
Editor IDisplay section of the Environment Options dialog box.
Select a color for the element. The element color in the sample code
reflects your selection. Use the left mouse button to select a foreground
color for the element (FG appears in the color). Use the right mouse
button to select a background color (BG appears in the color). If FB
appears in the color, the color is used as both a background and a
foreground color.
Choose an Attribute such as bold, if you want.
You can check Default FG (foreground) or BG (background) to use the
Windows default colors for an element.
Repeat steps 2-4 for the elements you want to modify.
Working with the Message window
You can customize
some of the
functionality of
message windows by
using Preferences in
the Environment
Options dialog box.
The Message window displays errors and warnings when you compile
programs. When you select a message in the Message window, the editor
places the cursor at the spot in your code where the error or warning
occurred. If the file containing the error isn't loaded in an editor window,
press Spacebar to load it (you can also press AIt+F10 and choose View source
from the SpeedMenu). The message window remains selected so you can
move from message to message.
To view the code associated with an error or a warning, either select the
message in the message window and press Enter, double-click the message,
or press AIt+F10 and choose Edit source from the SpeedMenu. The cursor
appears on the line and column in your source code where the error is most
Chapter 1, Getting started
15
likely to have occurred (the message window moves to the background).
Use AIt+F7 to move to the next error message or Alt+FB to go to the previous
error message.
You can also cursor through messages in the message window. As you
select a message, the cursor in the editor window moves to the place where
the error occurred (this is called automatic error tracking). Automatic error
tracking works only if theiile containing the errors is displayed in an editor
window. If the next message you select references another source file (not
the one in the current editor window), you must select the editor window
that displays the source file associated with the message before you can
continue automatic error tracking.
You can clear the message window by choosing Remove all messages from
the message-window SpeedMenu (right-click or press Alt+F10 to view the
SpeedMenu).
Browsing through your code
The browser lets you view the object hierarchies, classes, functions,
variables, types, and constants your program uses. The browser also lets
you
• Graphically view the hierarchies in your application, then select the
object of your choice and view the functions and symbols it contains and
inherits.
• List the variables your program defines, then select one and view its
declaration, list all references to it in your program, or edit its declaration
in your source code.
Before you use the browser, be sure to set these options in the Project
Options dialog box (choose Options IProject) and compile your application:
• Choose Compiler IDebugging and check Debug information in OBJs
• Choose Compiler IDebugging and check Browser reference information
in OBJs
• Choose Linker IGeneral and check Include debug information.
The Browser has a
customizable
SpeedBar (see page
12 for more
information on
customizing
SpeedBars).
16
To start the browser, choose Search IBrowse Symbol, View IClasses, or
View IGlobals. You can also place your cursor on a symbol in your code
and choose Search IBrowse symbol to bring up the browser. If the program
in the current editor window hasn't been compiled yet, you must compile
and link your program with debugging information before you can use the
browser. If you try to browse a class definition (or any symbol that doesn't
have symbolic debug information), you'll get an error message.
Borland C++ Users Guide
You can set several browser options using the Environment Options dialog
box. Choose Options IEnviro.nment, click the Browser topic and select the
options you want to use. Single window means you can only have only one
browser window up at a time; Multiple windows opens a' new browser
window each time you perform a browsing action (such as choosing View I
Globals from the main menu). Visible symbols are described on page 18.
Browsing through
objects (class
overview)
Choose View IClasses to see the "big picture," the object hierarchies in your
application, as well as the small details. When you choose View IClasses,
the browser draws your objects and shows their ancestor-descendant
relationships in a horizontal tree. The red lines in the hierarchy help you
see the immediate ancestor-descendant relationships of the currently
selected object more clearly. Figure 1.2 shows the structure of the WHELLO
application.
Figure 1.2
Viewing classes in an
application
To see more information on a particular object, double-click it. If you aren't
using a mouse, select the object by using your arrow keys and press Enter.
Filters
You can also check
the Browser options
in the Environment
Options dialog box to
select the type of
symbols, but you
must set these
options before
opening browser
windows.
When you browse a particular symbol, the same letters that identify the
symbol appear in a Filters matrix at the bottom of the browser window.
You can use filters to select the type of symbols you want to see listed. (See
Table 1.1 for a list of letters and their meaning.)
The Filters matrix has a column for each letter. Click the top or bottom row
to move the letter (a letter in the top row means the browser shows
symbols with that identification; a letter on the bottom means the browser
excludes symbols with that identification).
To restrict views of a particular type of symbol, click the bottom cell of the
letter's column as shown at left. For example, to remove all the variables
displayed in the currently selected object, click the bottom cell in the vcolumn.
In some cases more than one letter appears next to a symbol. The second
letter appears just after the letter identifying the type of symbol and further
describes the symbol. See Table 1.1 for a list of filter identifiers.
Chapter 1, Getting started
17
Viewing
declarations of
listed symbols
Use one of these methods to see the declaration of a particular symbol
displayed in a list:
• Double-click the symbol.
• Select the symbol and press Enter.
• Select the symbol, press Alt+F10 to view the SpeedMenu, then choose
Browse Symbol.
The symbol declaration appears in a window, as shown in Figure 1.3.
Figure 1.3
Symbol declaration
window
Browsing through
global symbols
Choose View IGlobals to open a window that lists every global symbol in
your application in alphabetical order. The browser lists the symbols (the
functions, variables, and so on) used in the object. Figure 1.4 shows the
globals for the WHELLO program.
Figure 1.4
Viewing globals
One or more letters appear to the left of each symbol in the object. The
,letters describe what kind of symbol it is. You can filter out symbols using
the filter list at the bottom of the browser window. See the previous section
"Filters" for more information.
Borland C++ Users Guide '
Table 1.1
Letter symbols in the
Browser
Letter
F
T
V
C
Functions
Types
Variables
Integral constants
.Debuggable
Inherited from an ancestor
Virtual method
?
v
You can also type
regular expressions
for searching (for
example, you can use
?, * and t).
Symbol
To get more information on a particular symbol, either click the symbol or
use your cursor keys to select it. A Search input box at the bottom of the
window lets you'quickly search through the list of global symbols by
typing the first few letters of the symbol's name. As you type, the highlight
bar in the list box moves to a symbol that matches the typed characters.
You can view the symbol declaration by selecting the symbol and pressing
Enter. See the previous section, "Viewing declarations of listed symbols," for
more information.
Using regular
expressions in the
browser
Table 1.2
Browser search
expressions
You can use expressions in the search box in some browser windows. See
Table 1.2 for a list of the symbols allowed.
Character
Function
Matches one of any character.
Matches zero or more of the previous character. For example,
* is an error because there is no previous character
fo* matches anything starting with an "f"
fo*x matches "fx", "fox","fooox"
Chapter 1, Getting started
t
Matches one or more of the previous character. For example,
t is an error
fot matches anything starting with "fo"
fotx matches "fox", '1000x"
?
Matches zero or one of the previous character. For example,
? is an error
f o? matches anything starting with "f"
fo?x matches only "fx" or "fox"
19
Browsing
symbols in your
code
You can also browse any symbol'in your code without viewing object
hierarchies or lists of symbols first. Choose from these methods:
• Highlight the symbol in your code and choose Search I Browse Symbol.
• Click the right mouse button or press Alt+F10when an editor window is
selected to display the SpeedMenu, then choose Browse Symbol.
Using command-line tools
Borland C++ contains several command-line tools that let you do the same
tasks you can do in the IDE. Borland C++ includes a command-line
compiler, a linker, a resource ~ompiler, a librarian, a project builder (called
MAKE), and other tools. Most of these tools are documented in this
manual. Some are documented in online files. All tools are documented in
the online Help.
You can use either the IDE or the command-line tools, because they
produce the same results, but you might choose to 'use the command-line
tools if you program using a DOS editor such as Brief. Here's a list of the
command-line tools, what they do, and where they are documented:
• BCC.EXE and BCC32.EXE are the 16-bit and 32-bit compilers. They are
documented in Chapter 3.
• TLINK.EXE and TLINK32.EXE link .OB] files and .LIB files to form .EXEs
and .DLLs. They are documented in Chapter 9.
• IMPLIB.EXE, and TLIB.EXE help you work with and create libraries.
They are described in Chapter 11.
• HC31.EXE compiles files for online Help and creates the .HLP file that
most Windows applications can use. It is documented in the online Help.
• BRCC.EXE, BRCC32.EXE, BRC.EXE, BRC32.EXE, and RLINK.EXE are
resource tools that compile resources for your applications. They are
described in Chapter 10.
• MAKE.EXE and MAKER.EXE help manage your projects by building
only the files that have changed since the last build. They are
documented in Chapter 12.
DPMI and the
command-line
tools
The command-line compiler uses DPMI (Dos Protected Mode Interface) to
run in protected mode on 286, 386, i486, or Pentium machines with at least
640K conventional RAM and at least 1MB extended memory.
Although Borland C++ runs in protected mode, it still generates
applications that run in real mode. The advantage to using Borland C++ in
20
Borland C++ Users Guide
protected mode is that the compiler has much more room to run than if you
were running it in real mode, so it can compile larger projects faster and
without extensive disk-swapping.
If you get "Out of Memory" errors from DOS (not running DOS from
Windows) when running the 32-bit command-line tools, create a swap file
with the MAKESWAP utility. MAKE SWAP takes the size of the file to
create in KBytes, for example:
Memory and
MAKESWAP,EXE
MAKESWAP 12000
creates a 12MB swap file called EDPMI.SWP in the current directory, which
the command-line tools use when they need additional memory. To ~et up
a swap file, use the DPMIMEM environment variable at the DOS prompt or
add this line to your AUTOEXEC.BAT file:
MAKESWAP applies
to DOS only, not to
DOS boxes opened
under Windows. See
the online file
INSTALL.TXT for
information on
running the tools from
DOS boxes.
set DPMIMEM=SWAPFILE \EDPMI.SWP
You must clear this environment variable before running Borland C++ 3.1
command-line tools or other 16-bit DPMI-hosted executables, suchas
Paradox. To clear the variable, type at the DOS prompt:
set DPMIMEM=
Borland C++ protected-mode applications (such as BCC and BCC32) use
the run-time managers RTM.EXE and 32RTM.EXE. The tools that use the
run-time manager first load the run-time manager, then do their work, and
then unload the run-time manager. If you're doing lots of calls to 32-bit
command-line tools that use the run-time manager (perhaps from a
makefile), you could speed up the process by loading the run-time manager
once, then calling the tools. To load the run-time manger, type 32RTM at the
command line. To unload the run-time manager, type 32RTM -u.
The run-time
manager and
tools
Controlling the
memory RTM uses
By default, the run-time manager consumes all available memory for itself
when it loads. It then allocates memory to its clients when they request it
through the memory manager API routines.
To control how much memory the run-time manager can use, at the DOS
command line add the RTM environment variable to your system's DOS
environment. Here is the syntax:
SET RTM=(option nnnnl
Chapter 1, Getting started
21
The following table lists the options you can use, where nnnn can be a
decimal number or a hex number in the form of xAB54 or xab54.
Table 1.3
Environment
variables for RTMs
memory allocation
Option
Description
EXTLEAVE nnnn
Always leave at least nnnn kilobytes of extended memory
available. The default value is 640K.
EXTMAX nnnn
Don't allocate more than nnnn kilobytes of extended memory. The
default value is 4 gigabytes. In Windows, the default value is onehalf the available memory.
EXTMIN nnnn
If fewer than nnnn kilobytes are. available after applying EXTMAX
and EXTLEAVE limits, terminate with an Out of Memory message.
The default value is zero.
REALLEAVE nnnn
Always leave at least nnnn paragraphs of real memory available.
The default value is 64K or 4096 paragraphs.
REALMAX nnnn
Don't allocate more than nnnn paragraphs of real memory. The
default value is 1 megabyte or 65,535 paragraphs.
REALMIN nnnn
If fewer than nnnn paragraphs are available after applying
REALMAX and REALLEAVE, terminate with an Out of Memory
message. The default value is zero.
Running other programs from the IDE
You can run other programs, tools, and utilities without leaving the IDE.
The IDE lets you run Turbo Debugger, Resource Workshop, GREP,
WinSight, WinSpector, and Keymapper. To run a program from the IDE,
choose Tools I ProgramName (for example, Tools I GREP).
To add programs to the Tools menu,
1. Choose Options I Tools. The Tools dialog box appears, listing Tools,
Viewers, and Translators.
2. Click New. If you want to add an existing tool (listed in the Tools dialog
box), click Edit.
3. Type the name of the program, its path, and any command-line options
you always want to pass to it. (You can use transfer macros on this
command line; see the online Help for more information.)
4. Type Menu text. This text can appear on SpeedMenus and on the Tools
main menu. If you want to assign a shortcut key to your menu text,
precede a letter with an ampersand-this letter will appear underlined
in the menu. For example, the shortcut key for File is F. In the menu
22
Borland C++ Users Guide
text, File would appear as &File. If you want an ampersand in your
menu text, use two ampersands (&&Test appears as &Test in the menu).
5. Type any help text you want. Help hint text appears in the status line
when you select the menu item.
6. Click Advanced. The Tool Advanced Options dialog box appears.
7. Check Translator if the program uses one file type to create another file
(like a compiler). Check Viewer if the program is used to view a file (like .
an editor).
8. Check Place on Tools menu. Check Place on SpeedMenu if you want the
program to appear on the SpeedMenu for the project window (see
Chapter 2 for more information on projects).
9. If your program is a Translator, type an extension for the files you want
to associate with the program. For example, BeC is a translator for.C
and .CPP files, so Translate From would show . c; . cpp:. Use a semicolon
to separate file extensions and a colon to designate the end of the list.
10. Type an extension for the resulting translated file. For example, Bee
converts .CPP files to .OBJ, so .obj appears in the Translate to box.
11. Choose OK with all the open dialog boxes,12. Choose Tool from the main menu to see that your program name was
added correctly to the Tool menu.
Chapter 1, Getting started
23
24
Borland C++ Users Guide
c
H
A
p
T
E
R
2
Using the project manager
Borland C++ 4.0 features a new project manager with expanded
functionality. This chapter describes how to use Borland C++ to build
applications and projects from your source code files and how to use .PRJ
files from previous versions of the project manager. If you have used earlier
versions of the project manager, read this chapter carefully.
The project manager handles applications that are built from many
components. Applications can have several source modules that must be
compiled with different options. For example, to create an .EXE, resource
scripts must be compiled with the resource compiler, import libraries must
be created, and .OBJs must be linked. ,
What is project management?
The project manager
reads .PRJ files from
previous releases.
The project manager organizes and updates complex applications by
keeping track of all the files and their interdependencies in a project file
with the extension .IDE.
Using the project manager is an efficient way to build projects because it
only translates the files that have changed since the last build of the project.
The term translate refers to using one file type to create another. For
example, the C++ compiler is a translator for .CPP files because it uses
them to generate .OBJ files (see page 40 for more information on
transla tors).
A project can be viewed as a list of files dependent on each other. Some files
are source code you create; others, like .OBJ files, .EXE files, and .DLL files
are produced by the compiler, linker, or other tools and are dependent on
your source code files.
Chapter 2, Using the project manager
25
In the project manager, dependencies are shown graphically (this is the
project tree). On each level, the files shown in a project are dependent on
the files indented beneath them, as shown in Figure 2.1.
Figure 2.1
The project tree
Project node
Target node----j--~B sample [.eKe)
[j cOwl [.obi)
Node ---t[f-.--- II sample [.epp)
II sample [.re)
II sample [.def)
Run-time_fl-+-_ [j bidsi [.lib)
node
[j owlwi [.lib)
[j import [.lib]
[j crUd" [.lib) <.Binlnclude>
In the project tree, different nodes have different icons.
• A project node represents the entire project. All the files used to build
that project appear under it (a project node is similar to a symbolic target
in a makefile). A project can contain many target nodes. For example,
you might have one project that you use to build two applications and a
DLL (three targets).
• A target node represents a file that is created when its dependent nodes
are built (a target is usually the .EXE or .DLL that you're creating from
source code). You can collapse a target node so that the dependent nodes
aren't displayed.
• A node generally refers to a file used to build a target. Files such as .C,
.CPP, .H, and .RC are source files associated with nodes.
• A run-time node refers to common files used at run time, such as startup
code (.LIB files). You can choose not to view these files (see page 29).
Creating a project
To create a project,
1. Choose Project I New project. Type a path and a name (eight characters
or less) for the project, then press Tab. You can also use the Browse
button to select a path to the project file.
2. Type a name for the first target in your project. This is usually the name
of the program you want to create (the .EXE or .DLL).
26
Borland C++ Users Guide
You can use
TargetExpert to
change these
attributes.
3. Choose a target type:
• Application is a normal.EXE file.
• Dynamic Library is a .DLL file.
• EasyWin is.a character-mode application that runs under Windows .
.• Static Library is a .LIB file.
• Import Library is a .LIB file.
• Windows Help is a help file (.HLP) that you usually access from a
Windows application (.EXE).
4. Choose a platform for your target:
•
•
•
•
Windows 3.x is a 16-bit Windows application.
Win32 is a 32-bit Windows NT application.
DOS Standard is a 16-bit DOS application.
DOS Overlay is a 16-bit DOS application that uses overlays.
5. If your application is for DOS, check
See the DOS
Reference for more
information on these
libraries.
•
•
•
•
•
•
•
•
•
•
Floating point to link in FP87.lib.
Emulation to link in EMU.LIB.
No Math to link in the DOS math libraries.
Alternate startup to link in COFx.OBJ, which makes SS==DS for all
memory models.
Check any standard libraries you want to use in your application.
Some libraries are checked by default when you choose a target type
(you can't uncheck some of these because they are required for the
type of target you're creating). If dynamic and static libraries exist,
you can choose which type you want to use (Dynamic is usually the
default).
OWL uses th~ ObjectWindows libraries. See the Object Windows
Programmer's Guide for more information.
Class Library uses the Borland container class libraries discussed in
the Programmer's Guide.
Runtime uses the run-time libraries listed in the Library Reference.
BWCC uses the Borland Windows Custom Control libraries. See
Appendix B..
BGI uses the Borland Graphics Interface (available for DOS
applications only). See the online file UTILS.TXT.
6. Check Diagnostic if you want to use a diagnostic version of the libraries
(this is available for Class Libraries and ObjectWindows; see the
Chapter 2, Using the project manager
27
ObjectWindows documentation for more information on diagnostic
versions of its libraries).
7. Check Multithread if you want to use the multithread version of the
run-time library. Multithread is available only if your platform is
Win32.
8. Choose a memory model for your target (Target Model). Models change
depending on the target type.
.
9. Click OK to create the project. A graphical representation of your
project appears in a project window. You can change the target
attributes you set in steps 2-8 by using the project manager's
SpeedMenu (right-click a node or press AIt+F10).
The project manager creates a target with one or more dependents-the
default dependents depend on the target type. To view which dependents
are added for a target type, click the Advanced button in the New Project
dialog box. You can select other dependent nodes, then click OK. For DOS
application, you can select how you want the stack and data segments to
work.
After you create the initial target for a project, you can add, delete; or
rearrange nodes and targets to your project. See page 31 for more
information on editing projects.
Creating a
multiple-target
project
To include a DLL for
an application in a
project, place the DLL
node under the .EXE
node.
Creating multiple-target projects is similar to creating projects with one
target:
1. Create a project using the steps described on page 26.
2. Choose Project I New target to add a second target to your application.
The New Target dialog box appears.
3. Type a name for the second target and choose a target type (Standard is
the default). Choose OK. The project manager adds a new target to your
project just as it does for the first target in a project.
To view a sample project with two targets, open the file MULTITRG.IDE in
the EXAMPLES\IDE\MULTITRG directory. This project file builds two
versions of the WHELLO program (one that is 16-bit and one that is 32-bit).
The project file contains a text file that describes how to use two or more
targets in one project file.
With more than one target in a project, you can choose to build a single
target, multiple targets, or the whole project. See page 30 for information on
building projects.
28
Borland C++ Users Guide
Converting old
projects
The project manager for this release can load and use projects from
previous versions of Borland C++ for Windows. Choose Project I Open
project, then type the name of the old project file. You can also change the
search attributes from * . IDE to * . PRJ to list the old 3.0 and 3.1 projects.'
The project manager converts the old project to a new one. Be sure to save
the new project if you want to keep using it with this version of Borland
C++. To save the project, choose Options I Save. Make sure Project is
checked, then click OK. The new project is saved with the old name and the
new .IDE extension.
Converting
projects to
makefiles
You can convert Borland C++ project files (.IDE) to makefiles (.MAK) from
the IDE. To convert a project file to a makefile,
1. Open the project file (.IDE) you want to convert.
2. Choose Project I Generate Makefile. The IDE generates a makefile with
the same name as the project file, but with the extension .MAK. The IDE
displays the new make file in an editor window.
Changing the'
Project View
The project window, by default, displays the project node, target, and
dependents. You can control the display by using the Options I
Environment dialog box.
1. Choose Options I Environment. The Environment Options dialog box
appears.
2. Choose Project View. A list of options appears.
3. Check or uncheck the options you want. A sample node called WHELLO
changes as you select or deselect options. This sample shows you how
all nodes will appear in the project window. The following list describes
each option:
Build translator displays the translator used on the node.
Code size displays the total size in bytes of code segments. This
information appears only after the node has been compiled.
Data s~ze displays the size in bytes of the data segment. This
information appears only after the node has been compiled.
Description displays a description of the node. You type the description
using the Edit node attributes dialog box from the SpeedMenu.
Location lists the path to the source file associated with the node.
Name displays the name of the node.
Chapter 2, Using the project manager
29
Number of lines displays the number of lines of code in the file
associated with the node (note that this displays only after you compile
the code).
Node type describes the type of node (for exainple, . cpp or . c).
Style Sheet names the Style Sheet attached with the node.
Output names the file (and the path to that file) that the node creates
when it is translated. For example, a .CPP node creates an .OBJ file.
Show runtime nodes displays the nodes the project manager uses when
the project is built. For example, it lists startup code and libraries.
Show project node displays the node for the entire project. The project
node is built when you choose Project IBuild all. Note that all targets are
dependents of the project node.
Building a project
To build a project,
1. Open the project you want to build using Project IOpen project from the
main menu.
2. Choose Project IBuild all from the main menu to build all the nodes in
the project, even if they're up-to-date. Or, choose Project IMake all to
build only the nodes whose dependents have changed since the last
project build.
The project manager builds the project using the Default Project Options
Style Sheet unless you have attached a different Style Sheet to a node or
overridden the options locally. See the section "Using Style Sheets" on
page 37 for more information.
.
The project manager starts at the first target and works down the project
until it comes to a node with no dependents. The project manager builds
that node first (and other nodes on the same level), then works back up the
project tree.
For example, if you have a project with an .EXE target that is dependent on
a .CPP file, the project manager builds the .CPP file to an .OBJ, and then the
project uses the new .OBJ file to create the .EXE.
If you choose Make all, the project manager checks a file's date and time to
seeif the file has been updated. If so, the project manager rebuilds that file,
then moves up the project tree and checks the next node's file date and
time. The project manager' checks all the nodes in a pr9ject and builds all
the out-of-date nodes.
30
Borland C++ Users Guide
Building part of a
project
There are three ways you can build part of a project:
• To build a node and its dependents,
1. Select the node you want to build.
2. Right-click the node (or press Alt+F10) and choose Build node from the
SpeedMenu. All the dependent nodes are built regardless of whether
they're out-of-date.
• To build a project using MAKE,
1. Select the node you want to build.
2. Right-click the node (or press AIt+F10) and choose Make node from the
SpeedMenu. MAKE builds only the nodes that aren't current. For more
information about MAKE and how it chooses which files to build, see
Chapter 12, "Using MAKE."
• To translate the individual node,
1. Select the node you want to translate.
2. Choose Project ICompile from the main menu or select the default
translation command from the SpeedMenu. For example, if you've
selected a .CPP file, the project SpeedMenu contains the command C++
Compile, which compiles only the selected node.
Project ICompile translates the current node if the project window is
selected. If an editor window is selected, Project ICompile translates the
text in the editor.
Editing the project tree
You can edit the project tree using keystrokes or menu commands. Some
menu commands appear only on the SpeedMenu. To display a SpeedMenu
in the Project window', right-click a node, or select a node and press AIt+F10.
The options available on the SpeedMenu reflect the type of selected node
and vary slightly among node types.
When editing projects, you can add, delete, and move targets and nodes,
and you can copy nodes. You can also change node and target attributes.
Chapter 2, Using the project manager
31
Editing target
attributes with
TargetExpert
Target attributes describe a target type. For example, a target can be a 16-bit
Windows DLL that you want to change to be 32 bits. You can change
attributes for Standard and AppExpert target types, but not for Source
Pools (see page 35 for information on Source Pools). Also, you can't change
a target type to be another target type (for example, you can't change a
Source Pool target to be an AppExpert target type).
To change a Standard or AppExpert target's attributes,
1. Select the target in the project window.
2. Press AIt+F10 or right-click the target node.
3. Choose TargetExpert from the SpeedMenu. The TargetExpert dialog
box appears.
4. Change the target attributes, then choose OK. Target attributes are
explained on page 27.
Editing node
attributes
Node attributes describe a node and define the options and translator used
when translating a node. To edit a node's attributes,
1. Select the node in the project window.
2. Press Alt+F10 or right-click the node.
3. Choose Edit node attributes from the SpeedMenu. The Node Attributes
dialog box appears.
4. Change the node attributes, then choose OK. Node attributes, which
usually display in the project window, are defined as follows:
Name is the name of the node.
Description is any text that describes the node.
Style Sheet is the name of the Style Sheet the project manager uses
when it translates that node. If «None» is specified, the project manager
uses the parent's Style Sheet.
Translator names the translator used on that node, which is usually the
default translator for the node type (CppCompile for a .CPP node). If
you change the translator, you'll override the default translator for this
node, affecting builds and makes for this node. See page 40 for more
information on translators.
Node type defines the node and the available translators tor that node.
32
Borland C++ Users Guide
Adding and
deleting a node
You can also use the
SpeedMenu to add
nodes. Press
AIt+F1O, then choose
Add node (you can
add one or more
nodes using this
command).
..
To add one node to the project,
1. Select the node you want the new node to appear under. If you want the
new node to appear under the target, select the target node.
2. Press Ins or right-click the selected node and choose Add node from the
SpeedMenu.
3. Choose the file or files you want associated with the new node, or type
the name of the node you want to add (if the file you type doesn't exist
in the current directory, the IDE creates the file).
4. Choose OK. The new node appears under the selected node.
If you want to add many nodes to a project,
1. Start the Windows File Manager and select the files you want to add as
nodes to your project. Make sure you can view the project window in
the IDE.
2. Drag the files from the File Manager. The project manager automatically
adds them under the selected node.
To delete a node in the project, select the node and press Del, or choose
Delete node on the SpeedMenu. You can delete many nodes by selecting
the ones you want to delete (use etrlor Shift with the left mouse button to
select multiple nodes), then pressing Del. The project manager asks if you
want to delete the nodes before it proceeds.
Adding and
deleting targets
To add a target to a project,
1. Choose Project I New target from the main menu.
2. Type the name for the new target and choose a target type:
Standard (default) can be an executable, DLL, or other file.
AppExpert is an ObjectWindows-based application. See Chapter 4 for
more information on this type of target.
Source Pool is a collection of files that can be referenced in other
targets. See page 35 for more information on using Source Pools.
3. Choose OK. If the target typeis Standard, the TargetExpert dialog box
appears so you can further define your target (see page 27 for more
information on these choices). If the target type is AppExpert, see
Chapter 4. If the target type is Source Pool, the target is added to the.
project and you can add nodes to it immediately.
Chapter 2, Using the project manager
33
..
To delete one or more targets,
1. Select the target and view the SpeedMenu (right-click the target or press
Alt+F10).
'
2. Choose Delete node.
3. The project manager asks if you're sure you want to delete the target.
Click OK. Note that you cannot undo this deletion.
Moving nodes and
targets
Copying nodes
You can move nodes and targets in several ways:
• Drag the node with the mouse. The node moves under the selected node
when you release the mouse button .
• Select the node and press Alt and the arrow keys. This moves the selected
node up or down through the visible nodes. You can also use Alt and the
right and left arrow keys to move a node through levels of dependencies.
For example, if you have a header file dependent on a .CPP file (so the .H
file appears under the .CPP in the project window), you can move the
header file to the same level as the .CPP file by selecting the header file
and pressing Alt+left arrow.
Nodes can be copied completely or by reference. A complete copy lets you
take the node and its attributes and put an identical, but separate, copy
somewhere in the project. A complete copy inherits the attributes from its
parent node unless you override any options.
A reference copy lets you take a node and its dependents and reference
them in another place in the project; a reference copy isn't distinct-if you
add or delete dependents of the original, the reference copy is also
updated. A reference copy is a copy of a node and its dependents.
To make a complete copy of a node,
1. Select the node or nodes you want to copy (use Shift or GIrl and the
mouse to select multiple nodes). If a node has dependents, the
dependents are copied automatically-you don't need to select them.
2. Hold down the Girl key and drag the selected nodes to where you want
to place the complete copies.
3. When you release the mouse button, the copied nodes appear. If you
edit the original node, the complete copy is not changed.
34
Borland C++ User's Guide
To make a reference copy,
1. Select the node you want to reference copy. You don't need to select the
node's dependents because they are copied automatically.
2. Hold down the Aft key and drag the selected node to where you want to
place the reference copy.
3. When you release the mouse button, the copied node appears. The
reference-copied node appears in a lighter (unbold) font. This helps you
remember that the copy is referenced rather than complete. If you edit
the original (such as adding or deleting dependents), all reference copies
are updated.
Warning!
If you delete an original node, all references to that node are also deleted.
You cannot undo this deletion.
'
Using Source Pools
A Source Pool is a collection of nodes. The Source Pool target isn't built, but
can be referenced during a build. Source Pools let different targets use a
common setof source code. One use for a Source Pool might be to create
two target applications-one 16-bit and the other 32-bit. To see a working
example of Source Pools, open the sample project called SRCPOOL.IDE in
the EXAMPLES\IDE\SRCPOOL directory. This project file includes a text
file that describes how the Source Pool is used in that example.
Source Pools can contain several files that you want to copy by reference in
your project. For example, you might have several header files that you
want to place throughout your project. If you place these files in a Source
Pool, then reference copy the Source Pool throughout the project, you only
have to update the original Source Pool. If you need to add a new header
file to the collection, you can add it in the original Source Pool and all the
referenced copies are automatically updated.
Source Pools are useful when you want to assign a single Style Sheet to
multiple targets. For example, if you have three targets in a project and you
want all the targets to use the same Style Sheet, you can either attach the
Style Sheet to each target individually, or you can move the targets under a
Source Pool; then attach the single Style Sheet to the Source Pool node. If
you want to reassign a Style Sheet (for example, you want to compile
without debug information), you only have to reassign the Style Sheet to
the Source Pool-not to each target.
Chapter 2, Using the project manager
35
Setting project options
Once you create a project, you might want to change the default build
options. These options tell the project manager how to build your project
(for example, they specify whether you want to include debugging
information in your application).
To change project options,
1. Choose Options IProject. A dialog box appears.
2. Edit the options you want to change. See Chapters 1 and 3 for a
description of the options.
3. Choose OK when you're done changing options.
When you build your project, the options you set are used for your entire
project. If you create a new project, it receives the project options from the
last open project.
There are times when you want to select different options for a specific node
in the project (for example, you might have a specific file you don't want
compiled with debugging information, but you want the rest of your files
to include debugging information). To use different options for a node, you
can use Local Override or a Style Sheet.
Local Override
Project options can be overridden locally. Local Override is useful when
you use project options, but you want to override a particular option for a
single node. If you want to override many options, use a separate Style
Sheet instead (see the next section on Style Sheets).
To override an option,
1. Choose the node whose options you want to override.
2. Right-click the node (or press Alt+F10) and choose Edit local options
from the SpeedMenu. The Style Sheet dialog box appears with the
options used for that node.
3. Select the option you want to override. The Local Override box is
checked automatically.
4. Click OK.
Caution!
36
To undo an override, uncheck Local Override. The checkmark in Local
Override shows only when the cursor is in the override option, which
makes it difficult to know which options you oyerrode. The Local Override
box is dark gray if no options in that section of 'options is overridden. The
Borland C++ Users Guide
box turns light gray if any option in that section is overridden, but you still
must select the individual options to find which one is overridden.
If you find yourself overriding more than one or two options, you might
want to create and use a separate Style Sheet for that node instead of using
Local Override.
Using Style
Sheets
Style Sheets are a collection of build options for a project. Every project uses
a default set of options. These "defaults" are saved in a Style Sheet, and by
default the project uses a Style Sheet called "Default Project Options". The
settings in the Style Sheet determine how the project is built. If all the
components in your project can be built with the same options, you can set
the options using the Options I Project dialog box (this is a way of editing
the "Default Project Options" Style Sheet. If you want to change options for
a single node, use Local Override, but if you find you're using Local
Override a lot, you might want to use Style Sheets.
When a project is built, the project's Style Sheet is used unless the node
being built references a different Style Sheet or uses Local Override (see
page 36 for information on using Local Override). You can use Style Sheets
and Local Override. You might want to do this if you attach Style Sheets to
your targets but want to slightly modify (override) the Style Sheet for a
node under the target.
When the project manager builds a node, it uses the node's Style Sheet and
any Local Override options. If the node doesn't have its own Style Sheet,
the project manager uses the Style Sheet of the node's parent. If the parent
node doesn't use a Style Sheet, the project manager looks at the next parent,
continuing until it uses the project's Style Sheet.
Different nodes in a project usually need to be built with different options.
For example, you might want to compile .C files with one set of options but
.CPP files with another. Or, you might want to build one target with 16-bit
options and another with 32-bit options. To see how Style Sheets can be
used in a project, open the project file called STYLESHT.IDE in the
directory \EXAMPLES\IDE\STYLESHT. This file uses Style Sheets for
each of the targets (two versions of WHELLO). The project also contains a .
text file that explains the use of Style Sheets.
Attaching a Style
Sheet to a node
The project manager contains several Style Sheets that you can use, but you
can also create your own. To attach an existing Style Sheet to a node,
1. Select the node and right-click it.
2. Choose Edit node attributes.
3. Select a Style Sheet from the list box.
Chapter 2, Using the project manager
37
4. Click OK.
You can also click the Styles button to create a new Style Sheet. See the next
section for more information on creating Style Sheets.
Creating a Style
Sheet
Editing Style Sheets
To create a Style Sheet for a project,
1.
2.
3.
4.
Choose Options IStyle Sheets from the main menu.
Click Create. Type a name for the Style Sheet and press Enter.
Click Edit. The Style Sheet dialog box appears.
Edit the options for your Style Sheet. Most options are described in
Chapter 3.
5. Click OK when you've completed setting the options for your new Style
Sheet.
You can edit, rename, and copy existing Style Sheets. Choose Options I
Style Sheets to view the Style Sheets dialog box. You can do any of the
following tasks from that dialog box:
Compose lets you create a Style Sheet that contains the combined options
from one or more Style Sheets:
1. Create a new Style Sheet (click New and type a name), then click
Compose.
2. Select a Style Sheet you want included in your new Style Sheet, then
click Add.
3. Continue adding Style Sheets, then click OK when you're finished. You
can't edit a composed Style Sheet, but you can click Compose again to
add or delete Style Sheets from the Composed one.
..
To copy a Style Sheet,
1. Select the Style Sheet you want to copy and then click Copy.
2. Type a name for the copied Style Sheet, then click OK. You can now
click Edit to change any of the copied options. Copying is a fast way to
create a Style Sheet that closely resembles another-you only have to
change the options you want.
..
To edit any Style Sheet,
1. Select the Style Sheet and click Edit.
2. Change the options you want, then click OK.
38
Borland C++ Users Guide
_
To rename a Style Sheet,
1. Select the Style Sheet and click Rename.
2. Type the new Style Sheet name, then click OK.
To remove a Style Sheet, select it and click Remove.
Sharing Style
.Sheets
Caution!
If you create Style Sheets for a project, then choose Project I New project, the
new project inherits the Style Sheets (and tools and options) from the old
project. However, if you close a project or restart the IDE, you'll have to
reopen the project with Style Sheets, then create a new project to inherit the
Style Sheets.
You can also share Style Sheets between projects another way. Every time
you create a project file (.IDE), you also create a Project Description
Language file (.PDL), which contains information about the Style Sheets
and Tools used in the project. Be careful when editing the text in this file
because you run the risk of corrupting the file to the point where the project
manager can't read it.
When you open a project file, the project manager opens the .PDL file with
the same name as the .IDE file.
To share a Style Sheet between projects,
1. Open the .PDL file containing the Style Sheet you want to share. You
can open the .PDL file using any text editor.
2. Search for the Style Sheet's name. For example, if you created a Style
Sheet called MYSTYLE, you'll see a section in the .PDL file that starts
{ StyleSheet
= "MYSTYLE".
3. Copy all the text from the beginning brace to the ending brace. You can
copy more than one Style Sheet.
4. Open the .PDL file to receive the copied Style Sheet.
5. Find the section for Style Sheets, then paste the copied text to the end of
the existing Style Sheet list.
6. Save the .PDL file that received the copied Style Sheet. When you open
the project associated with the updated .PDL file, you'll see the pasted
Style Sheets when you choose Options I Style Sheets.
Chapter 2, Using the project manager
39
Viewing options
in a project
Because each node can have its own Style Sheet and you can override the
options in the Style Sheet, you need a quick way to view the1options for
each node.
To view the hierarchy of options,
1. Right-click any node in the project and choose View options hierarchy.
The Options Hierarchy dialog box appears, listing the nodes in the
project and the options each uses. Autodependency nodes don't appear.
You can expand and collapse the list of nodes just like you can in the
project window.
2. Click a node you want to view. Its options appear to the right.
3. If you want to edit an option, double-click the option or select it and
then click Edit. If the option belongs to a Style Sheet, you'll be editing
the entire Style Sheet. If the option is a Local Override option, you'll be
editing the Local Override options for the selected node.
4. When you finish viewing node options, click Close.
The Options list shows the name of the node in square brackets followed by
the name of the Style Sheet for that node. It also lists any options that are
overridden for that node. This hierarchy lets you see what options are sent
to dependent nodes.
Translators
A translator is any program that changes (translates) one file type to
another. For example, the compiler is a translator that uses .C and .CPP files
to create .OBJs, and the linker is a translator that uses .OBI, .LIB, .DEF, and
.RES files to produce an .EXE file.
The project manager lets you define your own translators. Translators you
add to a project remain with that project file-they aren't added as
permanent parts of the IDE. However, translators, viewers, other tools, and
Style Sheets can be passed to the next project: if you have a project file open
that contains added-on tools or Style Sheets, the next project you create
(choose Project I New project) inherits the translators, viewers, other tools,
and Style Sheets from the previous project. For more information on .
sharing information between projects, see page 39.
You can view default translators by choosing Options I Tools-this list also
shows tools and viewers.
40
Borland C++ User's Guide
Installing a
translator
To install a translator,
1. Choose Options I Tools. A dialog box appears that lists Tools, Viewers,
and Translators. You can also install translators by choosing Build
Attributes from the project manager SpeedMenu.
2. Click New.
3. Type the name of the translator, the path to the translator, and any
command-line options for the translator. You can use transfer macros on
this command line. For more information on transfer macros, see the
online Help.
4. Type Menu text. This text can appear on SpeedMenus and on the Tools
main menu. If you want to assign a shortcut key to your menu text,
precede a letter with an ampersand-this letter will appear underlined
in the menu. For example, the shortcut key for File is F. In the menu
text, File would appear as &File. If you want an ampersand in your
menu text, use two ampersands (&&Test appears as &Test in the menu).
5. Type any help text you want. Help hint text appears in the status line
when you select the menu item.
6. Click Advanced. The Tool Advanced Options dialog box appears.
7. Check Translator.
8. Check Place on Tools menu if you want this translator to appear on the
Tools main menu. Check Place on SpeedMenu if you want it to appear
when you right-click a node associated with your translator.
9. Check Target translator if you want the translator to work on targets.
When you use this translator, the node becomes a target and the
translated file is saved to the Final directory. If you don't check Target
translator, the translated file is saved in the Intermediate directory.
10. Type an extension for the files you want to associate with this translator.
For example, BCC is a translator for .C and .CPP files, so Translate From
would show .c; .cpp:. Use a semicolon to separate file extensions and a
colon to designate the end of the list.
11. Type an extension for the resulting translated file. For example, BCC
converts .CPP files to .OBJ, so .obj appears in the Translate to box.
12. If you want your new translator to be the default for a node type, type
the file extension and a colon in the Default for box.
13. Choose OK.
Chapter 2, Using the project manager
41
Using Special on
the SpeedMenu
Installing viewers
and tools
When you display the SpeedMenu, some node types have a Special
command that lists other translators for the type of node you've selected.
For example, you see the commands Assembler Output and Preprocess if a
.CPP node is selected, but you see the command Implib if you selected a
.DLL target node.
Viewers let you see the contents of the selected node. For example, an
editor is a viewer that lets you examine the code in a .CPP file. On the
SpeedMenu for a .CPP node, you'll see the Text Edit command. The default
editor for the Text Edit view is the IDE editor.
To view a node, either
• Double-click it in the project window, or
• Right-click it and choose View to display a list of the available viewers.
Other node types have other viewers available. For example, Resource
Workshop can view .RC files. You can't view an .EXE node in a text editor,
but you can choose to view it using the integrated debugger, Turbo
Debugger for Windows, the ObjectBrowser, or even as an executing
program.
Tools are applications you want to run from the IDE, such as Turbo
Debugger and GREP. You can install viewers and tools just like you can
transla.tors. For more information, see the steps for installing a translator on
page 41.
42
Borland C++ User's Guide
c
H
A
p
T
E
R
3
Compiling
You can compile applications using either the IDE or the command-line
programs BCC.EXE (for 16-bit applications) or BCC32.EXE (for 32-bit
applications). You can control how the compiler generates code by using
compiler options that specify the type of application you want to build (a
debugging version for example), where to find header files and link
libraries, how C++ code is handled, and much more.
This chapter is organized into three parts:
• How to compile in the IDE
• How to compile with BCC or BCC32
• Compiler options reference
Table 3.1 cross-references the command-line compiler options with the IDE
options. Compiler options are discussed in detail according to their topic
groups in the Project Options dialog box.
Compiling in the IDE
This section describes how to compile simple programs using compiler
options in the IDE. To learn how to build large projects, read Chapter 2.
The IDE SpeedBar has three compiling buttons that correspond to menu
commands:
. Project I Compile (AIt+F9) compiles the code in the selected editor window
using the compiler options set in the Project Options dialog box. If a project
window is selected, all the selected nodes in the project are translated; child
nodes aren't translated unless they're selected (see Chapter 2 for
information on translators).
Project I Make all (F9) translates all the out-of-date nodes in a project. If no
project is open, all the files in edit windows are built using the default
project translators.
Chapter 3, Compiling
43
Project I Build all translates all nodes in a project-even if they are up-todate. Project I Build all always starts at the first project node and builds
down the project. Click Cancel to stop a build.
Using IDE
compiler options
There are two ways to set compiler options in the IDE:
• Choose Options I Project and set the options in the dialog box. These
options are used when you compile with no project file loaded. If a
project is loaded, these options affect the entire project when it is built.
• Set project options locally for each file; you must use the project manager
to do this. See Chapter 2 for information on local options.
For example, to compile code in an editor window (you don't have a
project loaded) that generates a 32-bit application for a 80386,
1. Select the editor window displaying the code to compile.
2. Choose Options I Project from the menu.
3. In the Project Options dialog box, click the 32-bit Compiler topic to
display the subtopics, then click Processor.
4. The Processor options for 32-bit appear on the right. Check 80386. This
option stays on until you change it or exit the IDE. To save the option as
a default (so that every time you compile, you get a 32-bit application
for a 80386), choose Options I Save from the main menu.
5. Click the Compile button on the SpeedBar, or choose Project I Compile
(this command compiles the code in the current editor window if no
project is loaded).
Using the command-line compilers
This section explains how to use the command-line compilers (BCC.EXE
and BCC32.EXE). BCC.EXE is a 16-bit application that generates 16-bit
code. BCC32.EXE is a 32-bit application that generates 32-bit code. BCC and
BCC32 work the same, but have different defaults (specified in Table 3.1)
and generate different code. Unless specified, instructions and options for
BCC also apply to BCC32.
You can use BCC to send files to TLINK or TASM (.ASM files if you have
TASM installed on your machine). The general syntax for BCC.EXE is
Bee [option [option ... ]] filename [filename . .. ]
To see a list of common compiler options, type Bee (without any options or
file names), then press Enter. The BCC command and each option and file
44
Borland C++ Users Guide
name must be separated by at least one space. Precede each option by
either a hyphen (-) or a forward slash (I); for example, to specify an
include path type:
BCC -Ic:\code\hfiles
Options and file names entered on the command line override settings in
configuration files.
By default, BCC compiles files without extensions and files with the .CPP
extension as C++ files. Files with a.C extension or with extensions other
than .CPP, .OBJ, .LIB, or .ASM compile as C files.
BCC.EXE and BCC32.EXE have options that are on by default (these
options are marked with bullets in Table 3.1). To turn off a default option,
type BCC -option-.
By default, BCC tries to link with a module-definition file with the same
name as the executable. Use TLINK to link with a module-definition file
with a different name. You can't link with more than one module-definition
file.
Configuration
files
TURBOC.CFG
configures BCC.EXE,
and BCC32.CFG
configures
BCC32.EXE; project
files (.IDE) configure
the IDE.
If you repeatedly use a certain set of options at the command-line, you
might want to list them in a configuration file (a standard ASCII text file). _
You must separate options by spaces; options can appear on one or more
.
lines.
By default, BCC.EXE uses a configuration file called TURBOC.CFG, and
BCC32.EXE uses BCC32.CFG (these defaults are marked with bullets in
Table 3.1). The compilers look for the .CFG files first in the directory where
you typed BCC, then in the directory where BCC.EXE or BCC32.EXE is
stored.
You can create multiple configuration files or modify TURBOC.CFG. To use
a configuration file, type + [path] filename at the BCC command line. For
example, to use a configuration file called MYCONFIG.CFG, you could use
the following command line:
BCC +C:\MYCONFIG.CFG mycode.cpp
Options typed on the BCC command line override configuration files.
Response files
Chapter 3, Compiling
To specify multiple options or files on the command line, place them in a
response file (a standard ASCII text file). Response files let you have a longer
command line than most operating systems allow.
45
To use response files,
1. Type the command-line options you want to use in a file and save the
file. Options can appear on one or more lines in the file, separated by
spaces. Response files s~pped with Borland C++ have the .RSP
extension.
2. TypeBCC @[path]respfile.rsp.
You can specify more than one response file by typing BCC
@[path] respfile. rsp @[path] otheresp. rsp. Options typed at the command
line override any option or file name in a response file.
Option
precedence rules
BCC.EXE and BCC32.EXE evaluate options from left to right, and follow
these rules:
• If you duplicate any option except -lor -L, the last option typed
_overrides any earlier one.
• If you list multiple -L or -I options on the command line, the result is
cumulative: the compiler searches all the directories listed, in order from
left to right.
• Options typed at the command line override configuration and response
file options.
Compiler options reference
Table 3.1 lists c~mpiler options for the IDE and the command line. Most
IDE options appear in the Project Options dialog box; if an option doesn't
appear in the Project Options dialog box, the IDE equivalent option or
command appears in angle brackets <>. Some topic names are abbreviated
or repeated in this table. You can find a more detailed explanation for each
option on the pages referenced in the table.
Default options for both 16- and 32-bit command-line compilers are marked
by a bullet (.); otherWise, the bullet is marked for 16-bit only default (.16) or
32-bit only default(.32). Note that defaults in the IDE are different. The
main default difference is that the IDE compiles with debug and browser
information, making your compiled files larger than if you compiled with
the command-line compilers (the applications will be the same size if you
use the same set of options for both IDE and command-line).
46
Borland C++ Users Guide
Table 3.1: Options summary
Option
.16
.32
•
Page IDE setting
@fiIename
45
Source Exif Data:
File Type : PDF
File Type Extension : pdf
MIME Type : application/pdf
PDF Version : 1.3
Linearized : No
XMP Toolkit : Adobe XMP Core 4.2.1-c043 52.372728, 2009/01/18-15:56:37
Create Date : 2013:01:15 19:13:55-08:00
Modify Date : 2013:01:15 22:29:38-08:00
Metadata Date : 2013:01:15 22:29:38-08:00
Producer : Adobe Acrobat 9.52 Paper Capture Plug-in
Format : application/pdf
Document ID : uuid:faa97905-722c-48f3-ba43-70dc30d6e9d0
Instance ID : uuid:f9106f5c-47bc-4289-b340-60ef3e91ede5
Page Layout : SinglePage
Page Mode : UseNone
Page Count : 462
EXIF Metadata provided by EXIF.tools