0% found this document useful (0 votes)
1K views

Borland C++ Version 3.1 Users Guide 1992

Uploaded by

Sridhar Yamijala
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views

Borland C++ Version 3.1 Users Guide 1992

Uploaded by

Sridhar Yamijala
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 238

3.

1
USER'S GUIDE
INTEGRATED ENVIRONMENT
OPTIMIZATION
COMMANDlINE COMPILER
INSTALLATION
BORLAND
Bar/ana C++
Version 3.1
BORLAND INTERNATIONAL, INC. 1800 GREEN HILLS ROAD
P.O. BOX 660001, SCOTTS VALLEY, CA 95067-0001
Rl
Copyright 1991, 1992 by Borland International. All rights reseNed.
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.
Windows, as used in this manual, refers to Microsoft's
implementation of a windows system.
PRINTED IN THE USA.
1098765
c o N T
Introduction 1
What's in Borland C++ ................. 1
Hardware and software requirements ... 4
The Borland C++ implementation ....... 4
The Borland C++ package . . . . . . . . . . . . .. 5
The User's Guide . . . . . . . . . . . . . . . . . . .. 5
The Tools and Utilities Guide ......... 6
The Programmer's Guide. . . . . . . . . . . .. 7
The Library Reference ............... 8
Using the manuals .................... 8
Programmers learning C or C++ ...... 9
Experienced C and C++ programmers . 9
Typefaces and icons used in these books . 10
How to contact Borland . . . . . . . . . . . . . .. 11
Resources in your package .......... 11
Borland resources . . . . . . . . . . . . . . . . .. 11
Chapter 1 Installing Borland C++ 13
Using INSTALL ..................... 14
Protected mode and memory ... ... . .. 15
DPMIINST .. .. .. . . .. .. .. . .. .. ... 15
DPMIMEM ..................... 16
DPMIRES . . . . . . . . . . . . . . . . . . . . . .. 16.
Extended and expanded memory .. 17
Running BC . . . . . . . . . . . . . . . . . . . . . .. 18
Laptop systems . . . . . . . . . . . . . . . . . . .. 18
The README file . . . . . . . . . . . . . . . . . . .. 18
The FILELIST.DOC and HELPME!.DOC
files ................................ 19
Example programs .................. 19
Customizing the IDE ................. 19
Chapter 2 IDE basics 21
Starting and exiting the DOS IDE ...... 22
Command-line options ............. 22
The Ib option ................... 22
The I d option ................... 23
E N T s
The I e option ................... 23
The Ih option ................... 23
The II option .................... 24
The 1m option. . . . . . . . . . . . . . . . . .. 24
The Ip option ................... 24
The Ir option .................... 24
The I s option. . . . . . . . . . . . . . . . . . .. 24
The I x option ................... 24
Exiting Borland C++ ............... 25
IDE components .. . . . . . . . . . . . . . . . . . .. 25
The menu bar and menus ........... 25
Shortcuts ....................... 26
Command sets .................. 26
Native option ................. 29
Borland C++ windows. . . . . . . . . . . . .. 30
Window management ............ 32
The status line . . . . . . . . . . . . . . . . . . . .. 33
Dialog boxes' . . . . . . . . . . . . . . . . . . . . .. 33
Action buttons ................... 34
Radio buttons and check boxes .... 34
Input and list boxes .............. 35
Configuration and project files . . . . . . . .. 36
The file ............... 36
Project files .... '. . . . . . . . . . . . . . . . . . .. 36
The project directory ............. 37
Desktop files .................... 37
Changing project files ............ 38
Default files ..................... 38
The Borland C++ for Windows IDE .... 38
Starting Borland C++ for Windows . .. 39
Command-line options ........... 39
Command sets .................... 39
Configuration and project files . . . . . .. 41
Using the SpeedBar ................ 41'
Global buttons . . . . . . . . . . . . . . . . . .. 42
Desktop window ............... : 42
Edit windows ................... 42
Project window .................. 42
Message window ................ 43
Chapter 3 Menus and options
reference 45
:: (System) menu ... . . . . . . . . . . . . . . . . .. 46
Repaint Desktop ................... 46
Transfer items ..................... 46
File menu . . . . . . . . . . . . . . . . . . . . . . . . . .. 47
New ............................. '47
Open ............................. 47
Using the File list box ............... 48
Save .............................. 49
Save As ........................... 49
SaveAll .......................... 49
Change Dir ....................... 50
Print ............................. 51
Printer Setup ...................... 51
DOS Shell . . . . . . . . . . . . . . . . . . . . . . . .. 51
Exit .............................. 52
Closed file listing .................. 52
Edit menu .......................... 52
Undo ............................. 53
Redo ............................. 53
Cut .............................. 54
Copy ............................. 54
Paste .................... ',' ., ..... 54
Clear ............................. 54
Copy Example . . . . . . . . . . . . . . . . . . . .. 55
Show Clipboard ................... 55
Search menu ........................ 56
Find .............................. 56
Replace ........................... 58
Search Again ...................... , 58
Go to Line Number ................ 59
Previous Error . . . . . . . . . . . . . . . . . . . .. 59
Next Error ........................ 59
Locate Function .................... 59
Runmenu ......................... .
Run ............................. .
Source code the same ............ .
S o u ~ c e code modified ............ .
Program Reset .................... .
59
59
60
60
61
Go to Cursor ................ ' ..... .
Trace Into ........................ .
Step Over ........................ .
Arguments ....................... .
Debugger ........................ .
Debugger Options ................ .
Compile menu ..................... .
Compile ......................... .
Make ............................ .
Link ............................. .
Build ............................ .
Information ...................... .
Remove Messages ................. .
Debugmenu ....................... .
Qualifying expressions ............ .
Inspect .......................... .
Ordinal Inspector windows ...... .
Pointer Inspector windows ....... .
Array Inspector windows ........ .
Structure and Union Inspector
windows ...................... .
Function Inspector windows ..... .
Class Inspector windows ......... .
Constant Inspector window ...... .
Type Inspector window .......... .
Evaluate/Modify ................. .
Call Stack ........................ .
Watches ......................... .
Add Watch ..................... .
Delete Watch ................... .
EditWatch ..................... .
Remove All Watches ............ .
Toggle Breakpoint ................ .
Breakpoints ...................... .
Project menu ....................... .
Open Project ..................... .
Close Project ..................... .
Add Item ........................ .
Delete Item ...................... .
Local Options .................... .
Include Files ..................... .
Browse menu ....................... .
Classes .......................... .
Functions ........................ .
61
61
62
63
64
64
64
64
65
65
65
66
66
66
67
68
69
69
70
70
71
71
71
71
71
73
75
75
75
75
76
76
76
78
78
79
79
79
79
81
81
82
82
Variables ......................... 83
Symbols .......................... 83
Rewind ........................... 83
Overview .. . . . . . . . . . . . . . . . . . . . . . .. 83
Inspect ........................... 84
Goto ............................. 84
Options menu ....................... 84
The Set Application Options dialog
box .............................. 84
Compiler ......................... 86
Code Generation . . . . . . . . . . . . . . . .. 86
Advanced Code Generation ... '.... 89
Entry /Exit Code ................. 91
C++ Options .................... 93
Advanced C++ Options. . . . . . . . . .. 95
Optimizations ................... 97
Source ......................... 100
. Messages. . . . . . . . . . . . . . . . . . . . . .. 100
Names ........................ 102
Transfer ......................... 102
Transfer macros ................ 104
Make ............................ 104
Linker ........................... 106
Settings . . . . . . . . . . . . . . . . . . . . . . .. 106
Libraries ....................... 108
Librarian ........................ 110
Debugger ........................ 110
Directories ....................... 113
Resources . . . . . . . . . . . . . . . . . . . . . . .. 114
Environment ..................... 114
Preferences ..................... 114
Editor ......................... 116
Highlight ...................... 118
Coloring your text ............ 118
Using the Windows system
colors ....................... 119
Changing text attributes ....... 119
Desktop ....................... 121
Startup ........................ 121
Colors ......................... 123
Save ............................. 123
Window menu ..................... 124
iii
Size/Move . . . . . . . . . . . . . . . . . . . . . .. 124
Zoom ........................... 124
Tile ............................. 124
Cascade ......................... 125
Arrange Icons .................... 125
Next ............................ 125
Close ............................ 125
Close All . . . . . . . . . . . . . . . . . . . . . . . .. 125
Message ......................... 125
Output .......................... 126
Watch ........................... 126
User Screen ...................... 127
Register ......................... 127
Project. . . . . . . . . . . . .. . . . . . . . . . . . .. 127
Project Notes .. . . . . . . . . . . . . . . . . . .. 127
List All .......................... 127
Help menu . . . . . . . . . . . . . . . . . . . . . . . .. 128
Contents . . . . . . . . . . . . . . . . . . . . . . . .. 129
Index ............................ 129
Topic Search ..................... 129
Previous Topic ................... 130
Help on Help . . . . . . . . . . . . . . . . . . . .. 130
Active File ....................... 130
About ........................... 130
Chapter 4 Managing multi-file
projects 131
Sampling the Project Manager ........ 132
Error tracking. . . . . . . . . . . . . . . . . . . . .. 135
Stopping a make . . . . . . . . . . . . . . . . .. 135
Syntax errors in multiple source files . 135
Saving or deleting messages . . . . . . .. 136
Autodependency checking ......... 137
Using different file translators ........ 138
Changing translator options ... . . . .. 138
Changing file translators ..... . . . . .. 139
Assigning a new file translator . . . . .. 139
Using the Project Manager to build
Windows applications .. . . . . . . . . . . . .. 140
Overriding libraries ................. 141
More Project Manager features ....... 141
Looking at files in a project ......... 143
Notes for your project ............. 143
Chapter 5 The command-line com-
piler 145
Using the command-line compiler ..... 145
DPMIINST . . . . . . . . . . . . . . . . . . . . . .. 146
Running BCC .................... 146
Using the options ................. 146
Option-precedence rules ......... 147
Syntax and file names ............. 150
Response files .................... 151
Configuration files ................ 151
Option-precedence rules ......... 152
Compiler options ................... 152
Memory model ................... 153
Macro definitions ................. 154
Code-generation options . . . . . . . . . .. 155
The -v and -vi options . . . . . . . . . .. 159
Optimization options .............. 160
Source-code options . . . . . . . . . . . . . .. 160
Error-reporting options ............ 162
ANSI violations. . . . . . . . . . . . . . . .. 162
Frequenterrors ................. 163
Portability warnings. . . . . . . . . . . .. 163
C++ warnings .................. 163
Segment-naming control .. . . . . . . . .. 164
Compilation-control options . . . . . . .. 165
Expanded and extended memory
options .......................... 168
C++ virtual tables. . . . . . . . . . . . . . . .. 168
C++ member pointers ............. 169
Template-generation options ....... 171
Linker options . . . . . . . . . . . . . . . . . . . . .. 171
Environment options ................ 172
Backward-compatibilityoptions ...... 173
Searching for include and library
files ............................. 174
File-search algorithms ............. 175
An annotated example ........... 176
Appendix A The Optimizer 179
When should you use the optimizer? . 179
Optimization options ................ 180
Backward compatibility .......... 181
iv
A closer look at the Borland C++
Optimizer. . . . . . . . . . . . . . . . . . . . . . .. 182
Global register allocation. . . . . . . .. 182
Dead-code elimination. . . . . . . . . .. 182
Common subexpression
elimination ..................... 183
Loop invariant code motion ...... 183
Copy propagation. . . . . . . . . . . . . .. 184
Pointer aliasing . . . . . . . . . . . . . . . .. 184
Induction-variable analysis and
strength reductio"n .............. 186
Loop compaction ............... 187
Code size versus speed
optimizations .................. 187
Structure copy inlining .......... 187
Code compaction ............... 187
Redundant load suppression ..... 188
Intrinsic function inlining ........ 188
Register parameter passing . . . . . .. 189
Object Data .................. 189
The _fastcall modifier .......... 190
Parameter rules ............... 190
Function naming. . . . . . . . . . . . .. 191
Appendix B Editor reference 193
Block commands ................ :. 195
Other editing commands. . . . . . . . . .. 197
Appendix C Usin"g EasyWin 199
DOS to Windows made easy ......... 199
Using EasyWin in a Windows
application ......................... 200
Added functions . . . . . . . . . . . . . . . . .. 201
Limitations. . . . . . . . . . . . . . . . . . . . . . . .. 201
Appendix 0 Precompiled headers 203
How they work . . . . . . . . . . . . . . . . . . . .. 203
Drawbacks . . . . . . . . .. . . . . . . . . . . . .. 204
Using precompiled headers .......... 204
Setting file names ................. 205
Establishing identity .............. 205
Optimizing precompiled headers 206
Index 209
T A B L E s
2.1: General hot keys ................... 27 3.4: DLL interdependencies ........... 109
2.2: Menu hot keys .................... 27 4.1: Project Manager defaults in the DOS
2.3: Editing hot keys ................... 28 IDE .............................. 140
2.4: Window management hot keys ...... 28 4.2: Project Manager defaults in the
2.5: Online Help hot keys .............. 28 Windows IDE .................... 140
2.6: Debugging/Running hot keys ....... 29 5.1: Command-line options summary ... 147
2.7: Manipulating windows ............ 32 A.1: Optimization options summary .... 180
2.8: General hot keys .................. 40 A.2: Parameter types and possible registers
2.9: Editing hot keys ................... 40 used ........................... 191
2.10: Online Help hot keys .............. 40 B.1: Editing commands ............... 193
2.11: Compiling/Running hot keys ..... .40 B.2: Block commands in depth ......... 196
3.1: Information settings ............... 66 B.3: Borland-style block commands ..... 197
3.2: Expression qualifiers ............... 67 B.4: Other editor commands in depth ... 197
3.3: Format specifiers recognized in
debugger expressions .............. 74
v
F G u R E s
2.1: A typical window ................. 31 3.14: The Entry/Exit Code Generation dialog
2.2: A typical status line ................ 33 box ............................. 91
2.3: A sample dialog box .. ; ............ 34 3.15: The C++ Options dialog box ....... 93
3.1: The Open a File dialog box ......... .47 3.16: The Advanced C++ Options dialog
3.2: The Save File As dialog box ......... 49 box ............................. 95
3.3: The Change Directory dialog box .... 50 3.17: The Optimization Options dialog
3.4: The Find Text dialog box ........... 56 box ............................. 97
3.5: The Replace Text dialog box ........ 58 3.18: The Transfer dialog box ........... 102
3.6: The Breakpoints dialog box ...... " ... 76 3.19: The Modify/New Transfer Item dialog
3.7: The Breakpoint Modify /New dialog box ............................ 103
box .............................. 77 3.20: The Make dialog box ............. 104
3.8: The Local Options dialog box ....... 79 3.21: The Linker dialog box ............ 106
3.9: The Borland C++ for Windows Local 3.22: The Libraries dialog box .......... 108
Options dialog box ................ 80 3.23: The Librarian Options dialog box .. 110
3.10: The Include Files dialog box ........ 81 3.24: The Debugger dialog box ......... 111
3.11: The Set Application Options dialog 3.25: The Highlighting dialog box ...... 118
box ............................. 85 3.26: The Startup Options dialog box ... 122
3.12: The Code Generation dialog box .... 87 3.27: The Colors dialog box ............ 123
3.13: The Advanced Code Generation dialog
box ............................. 89
vi
N T R
Borland C++ fully supports
Windows 3.1.
o D u c T o N
Borland C++ is a professional optimizing compiler for C++ and C
developers. With Borland C++, you get both C++ (AT&T version
3.0 compliant) and ANSI C. It is a powerful, fast, and efficient
compiler with which you can create practically any application,
including Microsoft Windows applications.
C++ is an object-oriented programming (OOP) language, and
allows you to take advantage of OOP's advanced design
methodology and labor-saving features. It's the next step in the
natural evolution of C. It is portable, so you can easily transfer
application programs written in C++ from one system to another.
You can use C++ for almost any programming task, anywhere.
What's in Borland C++
Chapter 1 tells you how to
install Borland C++. This
Introduction tells you where
you can find out more about
each of these features.
Introduction
Borland C++ includes the latest features programmers have asked
for:
.. C and C++: Borland C++ offers you the full power of C and
C++ programming, with a complete implementation of the
AT&T version 3.0 specification as well as a 100% ANSI C
compiler. Borland C++ also provides a number of useful C++
class libraries, plus the first complete commercial
implementation of templates, which allow efficient collection
classes to be built using parameterized types.
II Global optimization: A full suite of state-of-the-art optimization
options gives you complete control over code generation, so
you can program in the style you find most convenient, yet still
. produce small, fast, highly efficient code .
Faster compilation speed: Borland C++ cuts compilation time
for C++ by up to half. Precompiled headers significantly
2
The online file SAMPLES.DOC
describes each of the
sample programs.
shorten recompilation time. Optimizations are also performed
at high speed, so you don't have to wait for high-quality code.
DPMI compiler: Compile huge programs limited only by the
memory on your system. Borland C++ now uses industry-
standard DPMI (DOS Protected Mode Interface) to allow the
compiler (as well as the IDE, the linker, and other programs) to
run in protected mode under DOS or Windows 386 Enhanced
mode.
Microsoft Windows programming: Borland C++ provides
complete support for developing Windows applications,
including dynamic link libraries (DLLs). Supports Standard and
386 Enhanced mode under Windows 3.0 and 3.1. Added
support for Windows programming includes the Resource
Compiler, the Help Compiler, and the Resource Workshop.
We've also included many sample C and C++ Windows
applications to help get you going.
EasyWin: Automatic Windows-conversion feature lets you turn
many standard DOS applications using printf, scanf, and other
standard I/O functions into Windows applications without
changing a single line of code. Just set a single compiler switch
(or select Windows Application in the IDE), and your DOS
program runs in a window.
Programmer's Platform: Borland C++ comes with an improved
version of the Programmer's Platform, Borland's open-
architecture I1;)E that gives you access to a full range of
programming tools and utilities, including
a multi-file editor, featuring both an industry-standard
Common User Access (CUA) interface and a familiar
alternate interface that is compatible with previous versions
of Borland C++
advanced Turbo Editor Macro Language (TEML) and
compiler
multiple overlapping windows with full mouse support
color syntax highlighting to help you visually distinguish
elements in your source code
integrated resource compiling and linking, making it easy to
develop Windows applications in a single environment
fully integrated debugger running in DPMI, for debugging
large applications
a built-in assembler and support for inline assembler code
Borland C++ User's Guide
Introduction
complete undo and redo capability with an extensive buffer
and much more.
E:I Windows-hosted IDE: The Borland C++ for Windows IDE lets
you edit, compile, and run your programs under Windows, so
you don't have to task switch between Windows and a DOS
window to create Windows programs. This greatly increases
your productivity by allowing you to program, compile, link,
debug, and execute completely within the Windows
environment. The Borland C++ for Windows IDE also includes
built-in ObjectBrowser that lets you visually explore your
"class hierarchies, functions and variables, locate inherited
function and data members, and instantly browse the source
code of any element you select
o visual SpeedBar for instant point-and-click access to
frequently used menu selections
EJ WinSight: Windows message-tracing utility lets you see inside
your program's interaction with Windows.
IJ VROOMM: Borland C++'s Virtual Run-time Object-Oriented
Memory Manager lets you overlay your code without
complexity. You select the code segments for overlaying;
VROOMM takes care of the rest, doing the work needed to fit
your code into 640K.
I::J Help: Online context-sensitive hypertext Help, with copy-and-
paste program examples for practically every function.
a Streams: Borland C++ includes full support for c++ iostreams,
plus special Borland extensions to the streams library that allow
you to position text, set screen attributes, and perform other
manipulations to streams.
II Container classes: Advanced container class libraries giving
you sets, bags, lists, arrays, B-trees, and other reusable data
structures, implemented both as templates and as object-based
containers for maximum flexibility.
Ell Windows API: The complete Windows API documentation in
online Help.
Other features:
III Over 200 new library functions for maximum flexibility and
compatibility
1'1 Complex and BCD math, fast huge arithmetic
3
Heap-checking and memory-management functions, with far
objects and huge arrays
Run-time library in a DLL for Windows applications
New BGI fonts and BGI support for the full ASCII character set
Shared project, configuration, and desktop files to let
programmers work with the same environment whether they
use the Programmer's Platform or the Windows-hosted IDE
Response files for the command-line compiler
NMAKE compatibility for easy transition from Microsoft C
Hardware and software requirements
Borland C++ runs on the IBM PC compatible family of computers,
including the AT and PS/2, along with all true IBM-compatible
286,386 or 486 computers. Borland C++ requires DOS 3.31 or
higher, a hard disk, a floppy drive, and at least 640K plus 1MB of
extended memory; it runs on any 80-column monitor. Borland
C++ for Windows requires Windows 3.0 or higher in Standard or
386 Enhanced mode, at least 2MB of extended memory, and a
Windows-compatible monitor.
Borland C++ includes floating-point routines that let your pro-
grams make use of an 80x87 math coprocessor chip. Borland C++
emulates the chip if it's not available. Though it's not required to
run Borland C++, the 80x87 chip can significantly enhance the
performance of your programs that use floating-point math
operations.
Borland C++ also supports (but does not require) any Windows-
compatible mouse. The Resource Workshop requires a mouse.
The Borland C++ implementation
4
Borland C++ is a full implementation of the AT&T C++ version
3.0. It also supports the American National Standards Institute
(ANSI) C standard. In addition, Borland C++ includes certain
extensions for mixed-language and mixed-model programming
that let you exploit your PC's capabilities. See Chapters 1 through
4 in the Programmer's Guide for a complete formal description of
Borland C++.
Borland C++ User's Guide
The Borland C++ package
The User's Guide tells you
how to use this product: the
Programmer's Guide and the
Library Reference focus on
programming in C and C++:
the Too/s and Utilities Guide
describes and gives you
instructions for using
specialized programming
tools.
The User's Guide
Introduction
Your Borland c++ package consists of a sefof disks and nine
manuals:
Borland C++ User's Guide (this manual)
Borland C++ Tools and Utilities Guide
Borland C++ Programmer's Guide
Borland C++ Library Reference
Resource Workshop User's Guide
Turbo Debugger User's Guide
Turbo Profiler User's Guide
Turbo Assembler User's Guide
Turbo Assembler Quick Reference
The Borland C++ & Application Frameworks package also
contains the following manuals:
II Turbo Vision for c++ User's Guide
11 ObjectWindows for c++ User's Guide
In addition to these manuals, you'll find a convenient Quick
Reference card.
The disks contain all the programs, files, and libraries you need to
create, compile, link, and run your Borland C++ programs; they
also contain sample programs, many standalone utilities,
context-sensitive Help files, an integrated debugger, and
additional C and C++ documentation not covered in these guides.
The User's Guid,e introduces you to Borland C++ and shows you
how to create and run both C and C++ programs. It consists of in-
formation you'll need to get up and running quickly, and
provides reference chapters on the features of Borland C++:
Borland's Programmer's Platform, including the editor and Project
Manager, as well as details on using the command-line compiler.
These are the chapters in this manual:
The Introduction introduces you to Borland C++ and tells you
where to look for more mformation about each feature and
option.
5
6
The Tools and
Utilities Guide
Chapter 1: Installing Borland C++ tells you how to install Borland
C++ on your system; it also tells you how to customize the colors,
defaults, and many other aspects of Borland C++.
Chapter 2: IDE basics introduces the features of the Programmer's
Platform, giving information and examples of how to use the IDE
to full advantage. It includes information on how to start up and
exit from the IDE.
Chapter 3: Menus and options reference provides a complete
reference to the menus and options in the Programmer's Platform.
Chapter 4: Managing multi-file projects introduces you to Borland
C++'s built-in project manager and shows you how to build and
update large projects from within the IDE.
Chapter 5: The command-line compiler tells how to use the
command-line compiler. It also explains configuration files.
Appendix A: The Optimizer introduces the concepts of compiler
optimization, and describes the specific optimization strategies
and techniques available in Borland C++.
Appendix B: Editor reference provides a convenient command
reference to using the editor with both the CVA command
interface and the Borland C++ alternate interface.
Appendix C: Using EasyWin provides a guide to using EasyWin
to quickly and easily tum your DOS programs into applications
that run under Microsoft Windows.
Appendix 0: Precompiled headers tells you how to use Borland
C++'s precompiled headers feature to save substantial time when
recompiling large projects, especially Windows applications.
This volume introduces you to the many programming tools and
utility programs provided with Borland C++. It contains informa-
tion you'll need to make full use of the Borland C++ program-
ming environment, including the Make utility, the Turbo
Librarian and Linker, WinSight, and special utilities for Microsoft
Windows programming.
Chapter 1: Import library tools tells you how to use the IMPDEF,
IMPLIB, and IMPLIBW utilities to define and specify import
libraries. .
Borland C++ User's Guide
The Programme(s
Guide
Introduction
Chapter 2: Make: The program manager introduces the Borland
c++ MAKE utility, describes its features and syntax, and presents
some examples of usage.
Chapter 3: TUB: The Turbo librarian tells you how to use the
Borland C++ Turbo Librarian to combine object files into
integrated library (.LIB) files.
Chapter 4: TUNK: The Turbo linker is a complete reference to the
features and functions of the Turbo Linker (TLINK).
Chapter 5: Using WinSight provides instructions for using Win-
Sight to inspect your programs running under Microsoft
Windows.
Chapter 6: RC: The Windows Resource Compiler tells you how to
use the Resource Compiler to compile .RC scripts into .RES
resource files for your Windows programs.
Chapter 7: HC: The Windows Help Compiler contains instructions
for using the Help Compiler to create help systems for your
Microsoft Windows programs.
Appendix A: Error messages lists and explains run-time,
compile-time, linker, librarian, and Help Compiler errors and
warnings, with suggested solutions.
The Programmer's Guide provides useful material for the experi-
enced C user: a complete language reference for C and C++,
writing Windows applications, C++ streams, memory models,
mixed-model programming, video functions, floating-point
issues, and overlays, plus error messages.
Chapters 1 through 4: Lexical elements, Language structure, C++
specifics, and The preprocessor describe the Borland C++
language.
Chapter 5: Using C++ streams tells you how to use the C++
iostreams library, as well as special Borland C++ extensions for
Windows.
Chapter 6: The container class library tells you how to use the
Borland C++ container class library in your programs.
Chapter 7: Converting from Microsoft C provides some
guidelines on converting your Microsoft C programs to Borland
C++.
7
The Library
Reference
Chapter 8: Building a Windows application introduces you to the
concepts and techniques of writing applications for Microsoft
Windows using Borland C++.
Chapter 9: DOS memory management covers memory models,
mixed-model programming, and 'overlays.
Chapter 10: Math covers floating-point and BCD math.
Chapter 11: Video functions is devoted to handling text and
graphics in Borland C++.
Chapter 12: BASM and inline assembly tells how to write inline
assembly language functions that can be assembled with the
built-in assembler (BASM) and used within your Borland C++
program.
Appendix A: ANSI implementation-specific standards describes
those aspects of the ANSI C standard that have been left loosely
defined or undefined by ANSI, and how Borland has chosen to
implement them.
The Library Reference contains a detailed list and explanation of
Borland C ++'s extensive library functions and global variables.
Chapter 1: The main function describes the main function.
Chapter 2: The run-time library is an alphabetically arranged
reference to all Borland C++ library functions.
Chapter 3: Global variables defines and discusses Borland C++'s
global variables.
Appendix A: Library cross-reference provides a complete
indexed locator reference to all Borland C++ library functions.
Using the manuals
8
The manuals are arranged so that you can pick and choose among
the books and chapters to find exactly what you need to know at
the time you need to know it. The spine of each manual contains a
bulleted list of the major contents of that manual, making it easy
to pick up the right manual from your bookshelf. The User's Guide
provides information on how to use Borland C++ as a product;
Borland C++ User's Guide
Programmers
learning C or C++
Borland also offers its Visions
video training series: "World
of c++" for learning C++ and
"World of ObjectWindows for
C++" for learning Object-
Windows.
Experienced C
and C++
programmers
Introduction
the Programmer's Guide and the Library Reference provide material
on programming issues in C and C++.
Chapter 1 of this manual (the User's Guide) tells you how to install
Borland C++ and how to customize Borland C++'s defaults. Use
the remaining chapters of the User's Guide as reference chapters to
using Borland C++'s IDE, editor, project manager, command-line
compiler, precompiled headers, and online utilities.
If you don't know C or C++, there are many good products on the
market that can get you going in these languages. You can use
Chapters 1 through 5 in the Programmer's Guide for reference on
specific technical aspects of Borland C++.
Your next step is to start programming in C and C++. You'll find
Chapter 2, "The run-time library," in the Library Reference to be a
valuable reference on how to use each function. Chapter I, "The
main function," provides information about the main function
that is seldom found elsewhere. Or, you might prefer to use the
online Help; it contains much of the same information as the
Library Reference, and includes programming examples that you
can copy into your own Once you've grown
comfortable with programming, you might want to move into the
more advanced issues covered in the Programmer's Guide.
If you are an experienced C or C++ programmer and you've
already installed Borland C++, you'll probably want to jump
immediately to the Programmer's Guide and to the Library Reference.
The Programmer's Guide covers certain useful programming issues,
such as C++ streams, assembly language interface, memory
models, video functions, overlays, and far and huge pointers. If
you're interested in writing a Windows application in C++,
Chapter 8, "Building a Windows application," provides an
overview.
9
Typefaces and icons used in these books
Monospaced type
ALL CAPS
[ ]
<>
Boldface
Italics
Keycaps
All typefaces and icons used in this manual were produced by
Borland's Sprint: The Professional Word Processor, on a PostScript
laser printer.
This typeface represents text as it appears onscreen or in a pro-
gram. It is also used for anything you must type literally (such as
Be to start up Borland C++).
We use all capital letters for the names of constants and files.
Square brackets [ ] in text or DOS command lines enclose optional
items that depend on your system. Text of this sort should not be
typed verbatim.
Angle brackets in the function reference section enclose the names
of include files.
Borland C++ function names (such as printf), class, and structure
names are shown in boldface when they appear in text (but not in
program examples). This typeface is also used in text for Borland
C++ reserved words (such as char, switch, near, and cdecl), for
format specifiers and escape sequences (%d, \t), and for
command-line options (fA).
Italics indicate variable names (identifiers) that appear in text.
They can represent terms that you can use as is, or indicate that
you can think up new names for those terms (your choice,
usually). They are also used to emphasize certain words, such as
new terms.
This typeface indicates a key on your keyboard. For example,
"Press Esc to exit a menu."
This icon indicates keyboard actions.
This icon indicates mouse actions.
~ This icon indicates language items that are specific to C++. It is
used primarily in the Programmer's Guide.
101 This icon indicates material that applies to Borland C++ for
lEJ Windows, or that relates specifically to writing a Windows
program.
10 Borland C++ User's Guide
How to contact Borland
Resources in your
Borland offers a variety of services to answer your questions
about this product. Be sure to send in the registration card;
registered owners are entitled to technical support and may
receive information on upgrades and supplementary products.
package This product contains many resources to help you:
Borland resources
800-822-4269 (voice)
TechFax
408-439-9096 (modem)
File Download BBS
2400 Baud
Online information services
Introduction
III The manuals provide information on every aspect of the
program. Use them as your main information source.
III While using the program",You can press F1 for help.
c Many common questions are answered in the DOC files listed
in the README file located in the program directory.
Borland Technical Support publishes technical information sheets
on a variety of topics and is available to answer your questions.
TechFax is a 24-hour automated service that sends free technical
information to your fax machine. You can use your touch-tone
phone to request up to three documents per call.
The Borland File Download BBS has sample files, applications,
and technical information you can download with your modem.
No special setup is required.
Subscribers to the CompuServe, GEnie, or BIX information
services can receive technical support by modem. Use the
commands in the following table to contact Borland while
accessing an information service.
Service Command
CompuServe GO BORLAND
BIX JOIN BORLAND
GEnie BORLAND
Address electronic messages to Sysop or All. Don't include your
serial number; messages are in public view unless sent by a
service's private mail system. Include as much information on the
11
408-438-5300 (voice)
Technical Support
6 a.m. to 5 p.m. PST
408-438-5300 (voice)
Customer SeNice
7 a.m. to 5 p.m. PST
question as possible; the support staff will reply to the message
within one working day.
Borland Technical Support is available weekdays from 6:00 a.m.
to 5:00 p.m. Pacific time to answer any technical questions you
have about Borland products. Please call from a telephone near
your computer, and have the program running. Keep the
following information handy to help process your call:
Product name, serial number, and version number.
The brand and model of any hardware in your system.
Operating system and version number. (Use the DOS command
VER to find the version number.)
Contents of your AUTOEXEC.BAT and CONFIG.SYS files
(located in the root directory (\) of your computer's boot disk).
The contents of your WIN.lNI and SYSTEM.lNI files (located in
your Windows directory).
A daytime phone number where you ca'n be contacted.
If the call concerns a problem, the steps to reproduce the
problem.
Borland Customer Service is available weekdays from 7:00 a.m. to
5:00 p.m. Pacific time to answer any nontechnical questions you
have about Borland products, including pricing information,
upgrades, and order status.
Borland C++ User's Guide
c H
Your Borland C++ package
includes two different
versions of Borland C++: the
IDE (Programmer's Platform),
the DOS command-line
version, and Borland C++ for
Windows, which runs as a
true Windows application.
If you don't already know
how to use DOS commands,
refer to your DOS reference
manual before setting up
Borland C++ on your system.
A
p
T E R
1
Installing Borland C++
Borland C++ comes with an automatic installation program called
INSTALL. Because we use file-compression techniques, you must
use this program; you can't just copy the Borland C++ files onto
your hard disk. INSTALL automatically copies and uncompresses
the Borland C++ and Borland C++ for Windows files. For
reference, the README file on the installation disk includes a list
of the distribution files.
We assume you're already familiar with DOS commands. For
example, you'll need the DISKCOPY command to make backup
copies of your distribution disks. Make a complete working copy
of your distribution disks when you receive them, then store the
original disks away in a safe place.
None of Borland's products use copy-protection schemes. If
you're not familiar with Borland's No-Nonsense License State-
ment, read the agreement included with your Borland C++
package. Be sure to mail us your filled-in product registration
card; this guarantees you'll be among the first to hear about the
hottest new upgrades and versions of Borland C++.
This chapter contains the following information:
installing Borland C++ and Borland C++ for Windows on your
system
accessing the README file
accessing the HELPME! file
using Borland's example programs
Chapter 7, Installing Borland C++ 13
Using INSTALL
We recommend that you
read the README file before
installing.
INSTALL needs disk space to
store temporary files before
decompressing them.
INSTALL:S opening screen lists
the disk-space requirements:
if you don't have enough,
exit INSTALL and make room.
Once INSTALL is complete,
those temporary files are
deleted.
If you changed the default
installation directory, you
need to change this PATH
setting.
Important!
14
customizing Borland c++ (setting or changing defaults, colors,
and so on)
Once you've installed Borland C++, you'll be ready to start
exploring it. But certain chapters and manuals were written with
particular programming needs in mind. The User's Guide
Introduction tells where to find out more about Borland C++'s
features in the documentation set.
Among other things, INSTALL detects what hardware you're
using and configures Borland C++ appropriately. It also creates
directories as needed and transfers files from your distribution
disks (the disks you bought) to your hard disk. Its actions are
self-explanatory; the following text tells you all you need to know.
To install Borland C++:
1. Insert the installation disk (disk 1) into drive A. Type the
following command, then press Enter.
A: INSTALL
2. Press Enter at the installation screen.
3. Follow the prompts.
4. At the end of installation, you may want to add this line to
your CONFIG.SYS file:
FILES = 20
and this line to your AUTOEXEC.BAT file (or modify your
existing PATH statement, if you already have one):
PATH = C:\BORLANDC\BIN
When INSTALL is finished, it allows you to read the latest about
Borland C++ in the README file, which contains important,last-
minute information about Borland C++. The HELPME!.DOC file
also answers many common technical-support questions.
The next time you start Microsoft Windows (after you exit from
the README file viewer), a Borland C++ program group will be
created and installed in Program Manager. The program group
will contain icons for the following Borland C++ programs and
utilities:
Borland C++ DOS IDE
Borland C++ User's Guide
II Borland C++ for Windows
II Turbo Profiler
III Turbo Debugger for Windows
II Resource Workshop
.WinSight
II WinSpector
II Import Librarian
FCONVERT utility
Important! INSTALL assumes that Microsoft Windows is installed in the
directory you specified as your Windows directory during
installation. It also assumes that the Program Manager starts up
automatically as your Windows /I shell" when you start Windows.
If you normally use a different command shell from Program
Manager, you should edit the SYSTEM.INI file in your Windows
directory to include the line
Protected mode
SHELL=PROGMAN.EXE
Otherwise you'll get a message saying /I cannot communicate with
Program Manager" when you first open Windows and Borland
C++ tries to create a new Program Manager group. Once Borland
C++ for Windows and the other tools are installed in a Program
Manager group, you can examine their settings, then reinstall
them in your alternate command shell if you want.
and memory The Borland C++ DOS IDE and command-line compiler and tools
use DPMI (DOS Protected Mode Interface) to run the compiler in
protected mode, giving you access to all your computer's
memory. The protected-mode interface is completely transparent
to the user, and you should never have to even think about it,
with a few possible exceptions.
DPMIINST One such exception may be when you run Borland C++ for the
very first time. Borland C++ uses an internal database of various
machine characteristics to determine how to enable protected
mode on your machine, and configures itself accordingly. If your
machine is not recognized by Borland C++, you will receive an
error message saying
Machine not in database (RUN DPMIINST)
Chapter 7, Installing Borland C++ 15
DPMIMEM
16
If you get this message, simply run the DPMIINST program by
typing (at the DOS prompt)
DPMIINST
and following the program's instructions. DPMIINST runs your
machine through a series of tests to determine the best way of
enabling protected mode, and automatically configures Borland
C++ accordingly. Once you have run DPMIINST, you will not
have to run it again.
Some memory managers, device drivers, and memory-resident
(TSR) programs may interfere with DPMIINST's ability to analyze
your machine. If DPMIINST fails, try temporarily disabling or
removing these programs. That will give DPMIINST the
unrestricted access it needs to determine the best way to enter
protected mode.
By default, the Borland C++ DPMI interface will allocate all
available extended and expanded memory for its own use. If you
don't want all of the available memory to be taken by the DPMI
kernel, you can set an environment variable to specify the
maximum amount of memory to use. This variable can be entered
directly at the DOS prompt or inserted as a line in your
AUTOEXEC.BAT file, using the syntax
SET DPMIMEM=MAXMEM nnnn
where nnnn is the amount of memory in kilobytes.
For example, if you have a system with 4MB and want the DPMI
kernel to use 2MB of it, leaving the other 2MB alone, the
DPMIMEM variable would be set as follows:
SET DPMIMEM=MAXMEM 2000
When running under Windows in 386 Enhanced mode, it is not
necessary to set the DPMIMEM variable; instead, use the supplied
Windows PIF file (BORLANDC\ BIN\ BC.PIF) to configure the
amount of memory available to Borland C++.
Under Windows Standard mode, you must load the Borland
DPMI kernel before running Windows. This is done by running
DPMIRES.EXE (see the discussion of DPMIRES which follows).
When using DPMIRES in conjunction with Windows, always set
the DPMIMEM variable to less than the maximum available
memory to insure that Windows will have enough physical
memory to operate.
Borland C++ User's Guide
DPMIRES
Extended and
expanded memory
See the earlier section
"DPMIMEM" for more
information on restricting
how much memory the DPMI
server allocates for itself.
DPMIRES preloads the DPMI server. Preloading the DPMI server
lets you run the protected-mode tools (BC, BCC, T ASMX, TLINK,
MAKE, etc.) in Windows Standard mode DOS windows. Also,
since the tools don't need to load the DPMI server individually,
they load slightly faster.
When run, DPMIRES enables DPMI and spawns a DOS command
shell. The applications just mentioned load faster into this shell.
Type EXIT to close the shell.
DPMIRES is especially useful if you are compiling with MAKER
(the real mode MAKE) or with batch files, instead of using the
protected mode MAKE. In this situation, it will be more effiCient
to run DPMIRES and then run MAKER or the batch file, since the
compiler will load faster on each invocation.
If you are running under a DPMIRES shell, you may not run
Windows in 386 Enhanced mode, since the DPMI server, by
default, allocates all extended memory for its own use, leaving
none for Windows. You must first exit the shell and then run
Windows, or use the DPMIMEM variable to restrict the amount of
memory the DPMI server allocates.
Once the DPMI kernel is loaded (either by running BC or through
the DPMIRES utility), the Borland C++ IDE interacts directly with
the DPMI server to allocate its memory, both to load and while
operating. By default, the IDE uses all the extended memory
reserved by the DPMI kernel, and uses all available EMS
(expanded) memory as a swap device.
The Options I Environment I Startup dialog box and the Ix and Ie
command-line switches change this default behavior. These
settings do not affect the memory reserved by the kernel itself,
only how much of it the IDE uses.
The Use Extended Memory item and the Ix command-line option
tell the IDE how much of the memory reserved by the DPMI
kernel to use. The main reason for limiting the IDE's use of the
kernel's memory is to allow running of other DPMI applications
from within the IDE (using the transfer capability), or from a DOS
shell opened from the IDE.
The Use EMS Memory item and the Ie command-line option tell
the IDE how many 16K EMS pages to use as a swap device.
Chapter 7, Installing Borland C++ 17
Running Be
Laptop systems
The README file
18
Unless you tell the kernel to leave aside some available memory,
there will be no EMS memory available to the IDE.
Once you have installed Borland C++, if you're eager to get up
and running, type Be and press Enter. Or, you may wish to run
Borland C++ for Windows, by clicking on the Borland C++ for
Windows icon in the Program Manager. Otherwise, continue
reading this chapter and the next for important start-up
information.
After you have tried out the IDE, you may want to permanently
customize some of the options. The Options I Environment menus
make this easy to do.
If you have a laptop computer (one with an LCD or plasma
display), in addition to carrying out the procedures given in the
previous sections, you need to set your screen parameters before
using Borland C++. The IDE works best if you type MODE BW80 at
the DOS command line before running Borland C++.
Although you could create a batch file to take care of this for you,
you can also easily install Borland C++ for a black-and-white
screen from within the IDE, using the Options I Environment I
Startup option. Choose "Black and White / LCD" from the Video
options group.
The README file contains last-minute information that may not
be in the manuals.
Borland C++ automatically places you in the README file when
you run the INSTALL program. To access the README file at a
later time, you can use the Borland C++ README program by
typing this at the DOS command line:
CD \BORLANDC
README
Borland C++ User's Guide
The FILELIST,DOC and HELPME!.DOC files
Your installation disk also contains a file called FILELIST.DOC,
which lists every file on the distribution disks and a brief
description of what each one contains, and HELPMELDOC,
which contains answers to problems that users commonly run
into. Consult it if you find yourself having difficulties. You can
use the README program to look at FILELIST.DOC or
HELPMELDOC. Type this at the command line:
README HELPME!.DOC
or
README FILELIST.DOC
Example programs
Your Borland C++ package includes the source code for a large
number of example programs in C and C++ for both DOS and
Windows, including a complete spreadsheet program called
Turbo Calc. These programs are located in the EXAMPLES
directory (and subdirectories) created by INSTALL. The
EXAMPLES directory also contains subdirectories for examples of
the other tools and utilities that come with Borland C++ (like the
Turbo Assembler, Debugger, and Resource Workshop). Before you
compile any of these example programs, you should read the
printed or online documentation for them.
Customizing the IDE
For detailed information on
the menus and options in the
IDE (integrated development
environment), see Chapter 2,
"IDE basics," and Chapter 3,
"Menus and options
reference. "
Borland C++ lets you completely customize your installation from
within the IDE itself, using the various options that appear under
the Options I Environment menu. These options let you specify
the video mode, editing modes, menu colors, and default
directories, among others.
Chapter 7, Installing Borland C++ 19
20 Borland C++ User's Guide
c H A
p
T E R
2
IDE basics
Borland's Programmer's Platform, also known as the integrated
development environment or IDE, has everything you need to
write, edit, compile, link, and debug your programs. It provides
EiiI multiple, movable, rE-sizable windows
III mouse support and dialog boxes
color syntax highlighting
11 cut, paste, and copy commands that use the Clipboard
_ full editor undo and redo
_ online Help
examples ready to copy and paste from Help
_ a built-in assembler
_ an editor macro language
Borland C++ DOS IDE only _ quick transfer to other programs and back again
Chapter 2, IDE basics
This chapter explains the following topics:
_ starting and exiting the Borland C++ IDEs for DOS and
Windows
_ using IDE components
_ usirig configuration and project files
21
Starting and exiting the DOS IDE
Borland C++ runs only in
protected mode.
Command-line
To start the DOS IDE, type BC at the DOS prompt. You can follow
it with one or more IDE command-line options.
options The command-line options for the Borland C++ DOS IDE are Ib,
Id, Ie, Ih, II, 1m, lp, Ir, Is, and Ix using this syntax:
The /b option
See Chapter 4 for more
information on project files.
22
BC [option [option ... ]] [sourcename I projectname [sourcename]]
where option can be one or more of the options, sourcename is any
ASCII file (default extension assumed), and projectname is your
project file (it must have the .PRJ extension). The order and case is

To tum an option off, follow the option with a minus sign. For
example,
Be le-
turns off the default swap-to-expanded-memory option.
The Ib (build) option causes Borland C++ to recompile and link all
the files in your project, print the compiler messages to the
standard output device, and then return to the operating system.
This option lets you start Borland C++ from a batch file so you
can automate project builds. Borland C++ determines what .EXE
to build based on the file you specify on the command line. If it
doesn't find a project file, it builds the active file loaded into the
IDE edit window. It looks for project file (.PRJ) and source file
(.CPP) extensions.
To specify a project file, enter the BC command followed by Ib and
the project file name. For example,
Be Ib rnyproj.prj
If there is no MYPROG . PRJ file, the following command loads the
file MYPROG.CPP in the editor and then compiles and links it:
Be MYPROG IB
Borland C++ User's Guide
The /d option The Id option causes Borland C++ to run in dual monitor mode if
Borland C++ DOS IDE only it detects two video cards installed in your computer (for
example, a monochrome card and a color card); otherwise, the Id
option is ignored. Using dual monitor mode makes it easier to
watch a program's output while you debug the program.
If your system has two monitors, DOS treats one monitor as the
active monitor. Use the DOS MODE command to switch between
the two monitors (MODE C080, for example, or MODE MONO). In dual
monitor mode, the normal Borland C++ screen appears on the
inactive mon}tor, and program output goes to the active monitor.
When you type BC I d at the DOS prompt on one monitor, Borland
C++ comes up on the other monitor. When you want to test your
program on a particular monitor, exit Borland C++, switch the
active monitor to the one you want to test with, and then issue the
BC I d command again. Program output then goes to the monitor
where you typed the BC command.
Keep the following in mind when using the Id option:
c Don't change the active monitor (by using the DOS MODE
command, for example) while you're in a DOS shell (File I DOS
Shell).
[J User programs that directly access ports on the inactive moni-
tor's video card are not supported, and have unpredictable
results. .
IJ Don't use this option when you run or debug programs that
explicitly make use of dual monitors.
The / e option The / e option tells Borland C++ to swap to expanded memory if
Borland C++ DOS IDE only necessary; it is on by default. The syntax for this option is:
/e[=n]
where n equals the number of pages of expanded nlemory that
you want the IDE to use for swapping. Each page is 16K.
The /h option Typing BC Ih on the command line, you get a list of all the
Borland C++ DOS IDE only command-line options available. Their default values are also
shown.
Chapter 2, IDE basics 23
24
The II option Use the /I (lowercase 1) option if you're running Borland C++ on
Borland C++ DOS IDE only an LCD screen.
The 1m option The 1m option lets you do a make rather than a build. That is, only
Borland C++ DOS IDE only outdated source files in your project are recompiled and linked.
Follow the instructions for the Ib option, but use 1m instead.
The Ip option If your program modifies the EGA palette registers (or has BGI do
Borland C++ DOS IDE only it), use the Ip option, which controls palette swapping on EGA
video adapters. The EGA palette is restored each time the screen
is swapped.
The Ir option Use Irxto specify a swap drive, usually a RAM disk, if all your
Borland C++ DOS IDE only virtual memory fills up. The x in Irx is the letter of the swap drive.
For example, Ird specifies drive D as the swap drive.
The Is option Using the Is option (on by default), the compiler allows the
Borland C++ DOS IDE only majority of available memory to be allocated for its internal tables
while compiling. If it's compiling large modules, little memory
may remain for the needed overlays; therefore, the compiler may
spend a long time "thrashing;" that is, swapping overlays in and
out of memory.
If you specify Is-, the compiler won't permit its internal tables to
severely restrict the overlay space in memory. As a result, if you
are compiling very large modules, the compilation may fail and
you'll get an out-of-memory error.
The Ix option Use the Ix switch to tell Borland C++ how much of the available
Borland C++ DOS IDE only extended memory to use for its heap space. The following uses all
available memory:
Ix
The following switch, where n equals the amount of memory in
kilobytes, lets you specify how much extended memory should be
used:
Ix[=n]
Borland C++ User's Guide
Exiting Borland
C++
Borland C++ DOS IDE only
Borland C++ DOS IDE only
You return to the IDE after
you exit the program you
transferred to.
There are three ways to leave the IDE.
Choose File I Exit to leave the IDE completely; you have to type
Be again to reenter it. You'll be prompted to save your
programs before exiting, if you haven't already done so.
Choose File I DOS Shell to shell out from the IDE to enter
commands at the DOS command line. When you're ready to
return to the IDE, type EXIT at the command line and press Enter.
The IDE reappears just as you left it.
Choose a program from the System menu (=) to temporarily
transfer to another program without leaving the IDE. You can
add new Transfer programs with the Options I Transfer
command.
IDE components
The menu bar
and menus
Chapter 2, IDE basics
There are three visible components to the IDE: the menu bar at the
top, the window area in the middle, and the status line at the bot-
tom of the screen. Many menu items also offer dialog boxes.
Although there are several different ways to make selections in
the IDE, they access the same commands and dialog boxes. Before
we list menu items in the IDE, we'll explain these more generic
components.
The menu bar is your primary access to all the menu commands.
The menu bar is always visible except when you're viewing your
program's output or transferring to another program. .
If a menu command is followed by an ellipsis ( ... ), choosing the
displays a dialog box. If the command is followed by
an arrow the command leads to another menu. If the
command has neither an ellipsis nor an arrow, the action occurs
as soon as you choose the command.
Here is how you choose menu commands using the keyboard:
1. Press F10. This makes the menu bar active; the next thing you
type will relate to the items on the menu bar.
25
To cancel an action,
press Esc.
Borland C++ uses only the left
mouse button. You can,
however, customize the right
button and make other
mouse option changes, bV
choosing Options I
Environment I Mouse.
Shortcuts
Input boxes are described on
page 35.
26
2. Use the arrow keys to select the menu you want to display.
Then press Enter.
As a shortcut for this step, you can just press the highlighted
letter of the menu title. For example, when the menu bar is
active, press E to move to and display the Edit menu. At any
time, press Aft and the highlighted letter (such as Alt+E) to
display the menu you want.
3. Use the arrow keys again to select a command from the menu
you've opened. Then press Enter.
At this point, Borland C++ either carries out the command,
displays a dialog box, or displays another menu.
There are two ways to choose commands with a mouse:
Click the desired menu title to display the menu and click the
desired command.
Or, drag straight from the menu title down to the menu
command. Release the mouse button on the command you
want. (If you change your mind, just drag off the menu; no
command will be chosen.)
Some menu commands are unavailable when it would make no
sense to choose them. However, you can always get online Help
about currently unavailable commands.
Borland C++ offers a number of quick ways to choose menu
commands. The click-drag method for mouse users is an example.
From the keyboard, you can use a number of keyboard shortcuts
(or hot keys) to access the menu bar, choose commands, or work
within dialog boxes. You need to hold down Alt while pressing the
highlighted letter when moving from an input box to a group of
buttons or boxes. Here's a list of the shortcuts available:
Do this ...
Press Aft plus the highlighted
letter of the command (just
press the highlighted letter
in a dialog box). For the
:: menu, press Aft+Spacebar.
Type the keystrokes next to a
menu command.
To accomplish this ...
Display the menu or carry out the
command.
Carry out the command.
For example, to cut selected text, press Alt+E T (for Edit I Cut) or
you can just press Shift+Del, the shortcut displayed next to it.
Borland C++ User's Guide
Command sets Borland C++ has two command sets: the Common User Access
(CUA) command set and the Alternate command set popularized
in previous Borland products. The set you use determines the
shortcuts available to you, which keys you use within the editor,
and, to some extent, how the editor works. See more about using
command sets in the editor in Appendix B. A Native command
set option is discussed at the end of this section.
You can select a command set by choosing Options I
Environment I Preferences and then selecting the command set
you prefer in the Preferences dialog box. If you are a long-time
Borland language user, you may prefer the Alternate command
set.
The following tables list the most-used Borland C++ hot keys in
both command sets.
Table 2.1 : General hot keys
CUA Alternate Menu item
F1
Ctrl+F6
F7
FB
F9
F10
F1
F2
F3
F4
F5
F6
F7
FB
F9
F10
Help
File I Save
File I Open
Run I Go to Cursor
Window I Zoom
Window I Next
Run I Trace Into
Run I Step Over
Compile I Make
(none)
Table 2.2: Menu hot keys
CUA
Alt+Spacebar
Alt+C
Alt+D
Alt+E
Alt+F
AIt+H
Alt+O
Alt+P
Alt+R
Alt+S
Alternate
AJt+Spacebw
AJt+C
Alt+D
Alt+E
Alt+F
Alt+H
Alt+O
AJt+P
Alt+R
Alt+S
Chapter 2, IDE basics
Menu item
==menu
Compile menu
Debug menu
Edit menu
File menu
o Help menu
Options menu
Project menu
Run menu
Search menu
Function
Displays context-sensitive help screen
Saves the file that's in the active edit window
Brings up a dialog box so you can open a file
Runs your program to the line where the cursor is
positioned
Zooms the active window
Cycles through all open windows
Runs your program in debug mode, tracing into
functions
Runs your program in debug mode, stepping over
function calls
Invokes the Project Manager to make an .EXE file
Takes you to the menu bar
Function
Takes you to the == (System) menu
Takes you to the Compile menu
Takes you to the Debug menu
Takes you to the Edit menu
Takes you to the File menu
Takes you to the Help menu
Takes you to the Options menu
Takes you to the Project menu
Takes you to the Run menu
Takes you to the Search menu
27
Table 2.2: Menu hot keys (continued)
AIt+W
AIt+F4
A/l+W
A/l+X
Table 2.3: Editing hot keys
CUA Alternate
Window menu
File I Exit
Menu item
Takes you to the Window menu
Exits Borland C++ to DOS
Function
Clr/+/ns Ctr/+/ns Edit I Copy Copies selected text to Clipboard
Shift+Oe/ Shift+Oe/ Edit I Cut Places selected text in the Clipboard,
deletes selection
Shift+/ns Shift+/ns Edit I Paste Pastes text from the Clipboard into the
active window
Clr/+Oe/ Ctr/+Oe/ Edit I Clear Removes selected text from the window
but doesn't put it in the Clipboard
AIt+Backspace AIt+Backspace Edit I Undo Restores the text in the active window to
a previous state
A/t+Shft+Backspace A1t+Shft+Backspace Edit I Redo "Undoes" the previous Undo
F3 Ctr/+L Search I Search Again Repeats last Find or Replace command
F2 File I Save Saves the file in the active edit window
F3 File I Open Lets you open a file
Table 2.4: Window management hot keys
CUA Alternate Menu item
AIt+# A/t+#
AIt+O AIt+O Window I List All
Ctr/+F4 A/t+F3 Window I Close
Shift+FS Window I Tile
AIt+FS A/t+F4 Debug I Inspect
Shift+FS A/t+FS Window I User Screen
FS Window I Zoom
Ctr/+F6 F6 Window I Next
Ctr/+FS
Table 2.5: Online Help hot keys
CUA
F1
F1 F1
Shift+F1
AIt+F1
Ctrl+F1
28
Alternate
F1
F1 F1
Shift+F1
A/t+F1
Ctr/+F1
Menu item
Help I Contents
Help I Index
Help I Previous Topic
Help I Topic Search
Function
Displays a window, where # is the number of the
window you want to view
Displays a list of open windows
Closes the active window
Tiles all open windows
Opens an Inspector window
Displays User Screen
Zooms/ unzooms the active window
Switches the active window
Changes size or position of active window
Function
Opens a context-sensitive help screen
Brings up Help on Help. Gust press F1 when you're
already in the Help system.)
Brings up Help index
Displays previous Help screen
Calls up language-specific Help (in the active edit
window)
Bor/and C++ User's Guide
Table 2.6: Debugging/Running hot keys
CUA Alternate
Alt+FS AIt+F4
AIt+F7 AIt+F7
Alt+FB AIt+FB
AIt+F9 AIt+F9
Ctrl+F2 Ctrl+F2
Ctrl+F3
Ctrl+F4
Ctrl+FS Ctrl+F7
FS Ctrl+FB
Ctrl+F9 Ctr/+F9
F4
F7 F7
FB F8
F9 F9
Menu item Function
Debug I Inspect Opens an Inspector window
Search I Previous Error Takes you to previous error
Search I Next Error Takes you to next error
Compile I Compile to OBJ Compiles to .OBJ
Run I Program Reset Resets running program
Debug I Call Stack Brings up call stack
Debug I Evaluate/Modify Evaluates an expression
Debug I Add Watch Adds a watch expression
Debug I Toggle Breakpoint Sets or clears conditional breakpoint
Run I Run Runs program
Run I Go To Cursor Runs program to cursor position
Run I Trace Into Executes one line, tracing into functions
Run I Step Over Executes one line, skipping function calls
Compile I Make Makes (compiles/links) program
Native option
If you choose Options I Environment I Preferences to display the
Preferences dialog box, you'll notice a third command-set option:
Native. This is the default setting.
If you write applications for Windows, you may do some of your
development with Borland C++ and some with Borland C++ for
Windows. Both IDEs use the same configuration file,
TCCONFIG.TC, which determines which command set is in
effect. Therefore, if you have selected the CVA command set for
Borland C++ for Windows, that will be the one in effect the next
time you start up the Borland C++.
Native makes the Alternate
command set the default for
Borland C++, the DOS-hosted
IDE, and makes the CVA
command set the default for
Borland C++ for Windows.
But this may not be what you want. When you are working with
the DOS product, Borland C++, you might prefer the Alternate
command set, and when you use Borland C++ for Windows, you
might want to use the CVA command set. The Native option lets
this happen.
Chapter 2, IDE basics
With Native selected, Borland C++ uses the Alternate cOnlmand
set, and Borland C++ for Windows uses the CVA command set.
If you change the command set in either Borland C++ or Borland
C++ for Windows, you change it for both products.
While Native seems to imply that the default command set for
Borland C++ is Alternate, we recommend you choose the CVA
command set.
29
Borland C++
windows
If you exit Borland C++ with a
file open in a window, you
are returned to your desktop,
open file and 01/, when you
next use Borland C++.
30
Which command set you choose also determines which keys you
use within the editor, and, to some extent, how the editor works.
See more about using command sets in the editor in Appendix B.
Most of what you see and do in the IDE happens in a window. A
window is a screen area that you can open, close, move, resize,
zoom, tile, and overlap.
You can have many windows open in the IDE, but only one
window can be active at any time. Any command you choose or
text you type generally applies only to the active window. (If you
have the same file open in several windows, the action applies to
the file everywhere it's open.)
You can spot the active window easily: It's the one with the
double-lined border around it. The active window always has a
close box, a zoom box, and scroll bars. If your windows are over-
lapping, the active window is always on top of all the others (the
foremost one).
There are several types of windows, but most of them have these
things in common:
a title bar
II a close box
scroll bars
.azoom box
a window number (1 to 9)
An edit window also displays the current line and column num-
bers in the lower left corner. If you've modified your file, an aste-
risk ( * ) appears to the left of the column and line numbers.
The following figure shows a typical window:
Borland C++ User's Guide
Figure 2.1
A typical window
Shortcut: Double-click the
title bar of a window to zoom
or restore it.
Alt+D gives you a list of all
windows you have open.
(:hapter 2, IDE basics
Cl ick the

quickly close
the window.
I
The IJIIllII!!lD contains
the window.
., ., .,
[.]======= Window Title ====== :
I
The fi rst ni ne open
wi ndows have a IImI!!
1il!Iiil!mi. Use Alt and #
to make the # active.
Use a mouse to scroll the
contents of the wi ndow.

'---...1....-----------1 Drag any corner to make
wi ndows 1 arger or smaller.
The close box of a window is the box in the upper left corner. Click
this box to quickly close the window. (Or choose Window I Close.)
The Inspector and Help windows are considered temporary; you
can close them by pressing Esc.
The title bar, the topmost horizontal bar of a window, contains the
name of the window and the window number. Double-clicking
the title bar zooms the window. You can also drag the title bar to
move the window around.
The zoom box of a window appears in the upper right comer. If the
icon in that corner is an up arrow (1'), you can click the arrow to
enlarge the window to the largest size possible. If the icon is a
double-headed arrow (t), the window is already at its maximum
size. In that case, clicking it returns the window to its previous
size. To zoom a window from the keyboard, choose Window I
Zoom.
The first nine windows you open in Borland C++ have a window
number in the upper right border. You can make a window active
(and thereby bring it to the top of the heap) by pressing Aft in
31
Scroll bars also show you
where you are in your file.
W.
combination with the window number. For example, if the Help
window is #5 but has gotten buried under the other windows,
Alt+5 brings it to the front.
Scroll bars are horizontal or vertical bars that look like this:
~
" ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' C ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ............................... ~ 11 '111.11111 '1 11 ................................... '11 111' 1 1 ................ 11
11 11111111 .................. '11.II ........... 1 11 '11.1111 1 11.11111 111 111.111 111 11
You use these bars with a mouse to scroll the contents of the
window. Click the arrow at either end to scroll one line at a time.
(Keep the mouse button pressed to scroll continuously.) You can
click the shaded area to either side of the scroll box to scroll a
page at a time. Finally, you can drag the scroll box to any spot on
the bar to quickly move to a spot in the window relative to the
position of the scroll box.
You can drag any comer to make a window larger or smaller. To
resize using the keyboard, choose Size/Move from the Window
menu.
Window management Table 2.7 gives you a quick rundown of how to handle windows
in Borland C++. Note that you don't need a mouse to perform
these actions-a keyboard works just fine.
Table 2.7
Manipulating windows To accomplish this: Use one of these methods
-----------------------------------------------------
Opening an edit window Choose File I Open to open a file and
Opening other windows
Closing a window
Activating a window
display it in a window.
Choose the desired window from the
Window menu.
Choose Close from the Wmdow menu or
click the close box of the window.
Click anywhere in the window, or
Press Aft plus the window number (1 to 9,
in the upper right border of the window),
or
Choose Window I List or press AIt+O and
select the window from the list, or
Choose Window I Next to make the next
window active (next in the order you first
opened them).
Moving the active window Drag its title bar. Or choose Window I
Size/Move and use the arrow keys to place
the window where you want it, then press
Enter.
32 Borland c++ User's Guide
The status line
Table 2.7: Manipulating windows (continued)
Resizing the active window Drag any comer. Or choose Window I
Size/Move and press Shift while you use
the arrow keys to resize the window, then
press Enter.
Zoom the active window Click the zoom box in the upper right
corner of the window, or
Double-click the window's title bar, or
Choose Window I Zoom.
The status line appears at the bottom of the screen to
.. remind you of basic keystrokes and shortcuts (or hot keys)
applicable at that moment in the active window.
... let you click the shortcuts to carry out the action instead of
choosing the command from the menu or pressing the shortcut
keystroke .
Figure 2.2
A typical status line
Dialog boxes
Chapter 2, IDE basics
.. tell you what the program is doing. For example, it displays
Savingfilename ... when an edit file is being saved.
II offer one-line hints on any selected menu command and dialog
box items.
The status line changes as you switch windows or activities. One
of the most common status lines is the one you see when you're
actually writing and editing programs in an edit window. Here is
what it looks like:
Fl Help F2 Save F3 Open F7 Trace Fa Step F9 Make FlO Menu
When you've selected a menu title or command, the status line
changes to display a one-line summary of the function of the
selected item.
A menu command with an ellipsis ( ... ) after it leads to a dialog box.
Dialog boxes offer a convenient way to view and set multiple
options. When you're making settings in dialog boxes, you work
with five basic types of onscreen controls: action buttons, radio
buttons, check boxes, input boxes, and list boxes. Here's a sample
dialog box that illustrates some of these items:
33
Figure 2.3
A sample dialog box
If you have a color monitor,
Borland C++ uses different
colors for various elements of
the dialog box.
Action buttons
You can select another
button with Tab: press Enter to
choose that button.
34
Radio buttons and
check boxes
( ) None
(e) Emulation
( ) 8087
( ) 80287/387
[X] Checked check box
[ ] Unchecked check box
This dialog box has three standard buttons: OK, Cancel, and Help.
If you choose OK, the choices in the dialog box are accepted; if
you choose Cancel, nothing changes, no action takes place, and
the dialog box is put away. Choose Help to open a Help window
about this dialog box. Esc is always a keyboard shortcut for
Cancel (even if no Cancel button appears).
If you're using a mouse, click the dialog-box button you want.
When you're using the keyboard, press Alt and the highlighted
letter of an item to activate it. For example, Alt+K selects the OK
button because the K in OK is highlighted. Press Tab or Shift+Tab to
move forward or back from one item to another in a dialog box.
Each element is highlighted when it becomes active.
In this dialog box, OK is the default button, which means you need
only press Enter to choose that button. (On monochrome systems,
arrows indicate the default; on color monitors, default buttons are
highlighted.) Be aware that tabbing to a button makes that button
the default.
Radio buttons are like car-radio buttons. They come in groups,
and only one radio button in the group can be on at anyone time.
To choose a radio button, click it or its text. From the keyboard,
select Aft and the highlighted letter, or press Tab until the group is
highlighted, and then use the arrow keys to choose a particular
radio button. Press Tab or Shift+ Tab again to leave the group with
the new radio button chosen.
Check boxes differ from radio buttons in that you can have any
number of check boxes checked at any time. When you select a
check box, an x appears in it to show you it's on. An empty box
indicates it's off. To change the status of a check box, click it or its
text, press Tab until the check box is highlighted and then press
Spacebar, or select Alt plus the highlighted letter.
Borland C++ User's Guide
Input and list boxes
You can control whether
history lists are saved to the
desktop using Options I
Environment I Desktop.
Chapter 2, IDE basics
If several check boxes apply to a topic, they appear as a group. In
that case, tabbing moves to the group. Once the group is selected,
use the arrow keys to select the item you want, and then press
Spacebar to check or uncheck it. On monochrome monitors, the -
active check box or group of check boxes will have a chevron
symbol () to the left and right. When you press Tab, the chevrons
move to the next group of check boxes or radio buttons.
Input boxes let you type in text. Most basic text-editing keys work
in the text box (for example! arrow keys, Home, End, and Ins). If you
continue to type once you reach the end of the box, the contents
automatically scroll. If there's more text than shows in the box,
arrowheads appear at the end (<III and ~ ) . You can click the
arrowheads to scroll or drag the text. If you need to enter control
characters (such as "L or "M) in the input box, then prefix the
character with a "P. So, for example, to enter "L into the input
box, hold down the etr/key and press P L. (This capability is useful
for search strings.)
If an input box has a down-arrow icon ( ~ ) to its right, there is an
associated history list. Click the ~ to display the list. You'll find text
you typed the last few times you used the input box. Press Enter to
choose an item from this list. The Find box, for example, has such
a history list, which keeps track of the text you searched for
previously. Try choosing a previous search string. You can also
edit an entry in the history list. Press Esc to exit from the history
list without making a selection.
Here is what a history list for the Find text box might look like if
you had used it six times previously:
Text to find 0
struct date
printf(
char buf[7]
/*
returneD
returnO
A final component of many dialog boxes is a list box, which lets
you scroll through and select from variable-length lists (often file
names) without leaving a dialog box. If a blinking cursor appears
in the list box and you know what you're looking for, you can
35
type the word (or the first few letters of the word) and Borland
c++ will search for it.
You make a list box active by clicking it or by choosing the high-
lighted letter of the list title (or press Tab until it's highlighted).
Once a list box is displayed, you can use the scroll box to move
through the list or press t or J, from the keyboard.
Configuration and project files
The configuration
file
Project files
36
With configuration files, you can specify how you want to work
within the IDE. Project files contain all the information necessary
to build a project, but don't affect how you use the IDE.
The IDE configuration file, TCCONFIG.TC, contains only
environmental (or global) information, including
editor-key binding and macros
editor-mode setting
mouse preferences
auto-save flags
The configuration file is not needed to build programs defined by
a project. The project (.PRJ) file handles those details.
When you start a programming session, Borland c++ looks for
TCCONFIG.TC first in the current directory and then in the
directory that contains BC.EXE. Borland c++ for Windows also
looks in the current directory but, if it doesn't find
TCCONFIG.TC, it looks in the directory that contains BCW.EXE.
The IDE places all information needed to build a program into a
binary project file, a file with a .PRJ extension. Project files contain
the settings for:
compiler, linker, make, and librarian options
directory paths
the list of all files that make up the project
special translators (such as Turbo Assembler)
Borland C++ User's Guide
The project directory
Desktop files
You can set some of these
options on or off using
Options I Environment I
Desktop.
Chapter 2, IDE basics
In addition, the project file contains other general information on
the project, such as compilation statistics (shown in the project
window) and cached autodependency information.
IDE .PRJ project files correspond to the .CFG configuration files
that you supply to the command-line compiler (the default
command-line compiler configuration file is TURBOC.CFG). The
PRJCFG utility can convert .PRJ files to .CFG files and .CFG files
to .PRJ files.
You can load project files in any of three ways:
1. When starting Borland C++, give the project name with the
.PRJ extension after the Be command; for example,
Be myproj.PRJ
You must use the :PRJ extension to differentiate it from source
files.
2. If there is only one .PRJ file in the current directory, the IDE
assumes this directory is dedicated to the project and
automatically loads it.
3. To load a project from within the IDE, select Project I Open
Project.
When a project file is loaded from a directory other than the
current directory, the current DOS directory is set to where the
project is loaded from. This allows your project to be defined in
terms of relative paths in the Options I Directories dialog box and
also allows projects to move from one drive to another or from
one directory branch to another.
Changing directories after loading a project may make the relative
paths incorrect and your project unbuildable. If this happens,
change the current directory back to where the project was loaded
from.
Each project file has an associated desktop file (prjname.DSK) that
contains state information about the associated project. While
none of its information is needed to build the project, all of the
information is directly related to the project. The desktop file
includes
the context information for each window of the desktop (for
example, your positions in the files or bookmarks)
37
Changing project files
Default files
In Borland C++ for Windows,
the default files are
TCDEFWDPR and
TCDEFWDSK.
the history lists for various input boxes (for example, search
strings or file masks)
the layout of the windows on the desktop
the contents of the Clipboard
watch expressions
'" breakpoints
Because each project file has its own desktop file, changing to
another p'roject file causes the newly loaded project's desktop to
be used, which can change your entire window layout. When you
create a new project (by using Project I Open Project and typing in
a new .PRJ file name), the new project's desktop inherits the
previous desktop. When you select Project I Close Project, the
default project is loaded and you get the default desktop and
project settings.
When no project file is loaded, there are two default files that
serve as global placeholders for project- and state-related informa-
tion: TCDEF.DPR and TCDEF.DSK files, collectively referred to as
the default project.
These files are usually stored in the same directory as BC.EXE,
and are created if they are not found. When you run the IDE from
a directory without loading a project file, you get the desktop and
settings from these files. These files are updated when you change
any project-related options (for example, compiler options) or
when your desktop changes (for example, the window layout).
When you start a new project, the options you set for your
previous project will be in effect.
The Borland C++ for Windows IDE
38
The Borland C++ for Windows IDE has everything you need to
write, edit, compile, and link your programs in a Windows-
hosted environment. You can even start up the powerful Turbo
Debugger for Windows without leaving the IDE.
The Borland C++ for Windows IDE is based on Windows
Multiple Document Interface (MDI). If you are familiar with other
Windows programs, you'll feel right at home with the IDE.
Borland C++ User's Guide
Starting Borland
C++ for Windows As you do with other Windows products, double-click the
Borland c++ for Windows icon in the Program Manager to start
Borland C++ for Windows.
If you have more than one project, you might want to create an
icon for each project. Here's how to create a project icon in the
Windows Program Manager:
Choose File I New.
Select Program Item and the New Program Object dialog box
appears.
Type in a description for your project, and, in the command-
line text box, type BCW followed by the project file name
including the full path.
Now when you double-click the icon in the Program Manager,
your project will load into Borland C++ for Windows.
Command-line options You can specify two command-line options when you start
Borland C++ for Windows: Ib for building a project or 1m for
doing a make on a project. To specify either of these options:
Command sets
Chapter 2, IDE basics
Select the Borland C++ for Windows icon in the Program
Manager.
c Choose File I Run.
Add the command-line option you want to the command line
in the command-line text box and choose OK.
When you use either of these options, your messages are
appended to a file named the same as your project file ~ x c e p t it
carries the extension .MSG. For example, if your project file is
MYPROJ.PRJ, the message file is MYPROJ.MSG.
Just as the Borland C++ DOS IDE does, Borland C++ for
Windows has two command sets: the Common User Access
(CUA) command set used by most Windows programs, and the
Alternate command set. The menu shortcuts available to you
differ depending on which command set you use. You can select a
command set by choosing Options I Preferences and then selecting
the command set you prefer in the Preferences dialog box.
39
Here are the menu shortcuts in the Borland C++ for Windows
IDE:
Table 2.8: General hot keys
CUA Alternate
F2
F3
AIt+F4 AIt+X
Alt+Space AIt+Space
Menu item
File I Save
File I Open
File I Exit
(none)
Function
Saves the file that's in the active edit window
Brings up a dialog box so you can open a file
Exits Borland C++ for Windows
Takes you to the Control menu
Table 2.9: Editing hot keys
CUA Alternate Menu item Function
Ctrl+lns Ctrl+lns Edit I Copy Copies selected text to Clipboard
Shift+Del Shift+Del Edit I Cut Places selected text in the Clipboard,
deletes selection
Shift+lns Shift+lns Edit I Paste Pastes text from the Clipboard into the
active window
Ctrl+Del Ctrl+Del Edit I Clear Removes selected text from the window
and doesn't put it in the Clipboard
AIt+Backspace AIt+Backspace Edit I Undo Restores the text in the active window to
a previous state.
AIt+Shft+Backspace Alt+Shft+Backspace Edit I Redo "Undoes" the previous Undo.
F3 Ctrl+L Search I Search Again Repeats last Find or Replace command
Table 2.10: Online Help hot keys
CUA
Shift+F1
Ctrl+F1
Alternate
Shift+F1
Ctrl+F1
Menu item
Help I Index
Help I Topic Search
Table 2.11: Compiling/Running hot keys
CUA
Alt+F7
Alt+FB
Ctrl+F9
F9
Alt+F9
40
Alternate
AIt+F7
Alt+FB
Ctrl+F9
F9
AIt+F9
Menu item
Search I Previous Error
Search I Next Error
Run I Run
Compile I Make
Compile I Compile ,
Function
Brings up Help index
Calls up language-specific Help in the active edit
window
Function
Takes you to previous error
Takes you to next error
Runs program
Invokes Project Manager to make an .EXE, .DLL,
or .LIB file
Compiles file in active edit window
Borland C++ User's Guide
Configuration
and project files
Using the
SpeedBar
Chapter 2, IDE basics
Although there are only two command sets, there is a third
command-set option: Native. It's purpose is to make switching
between the Borland C++ and the Borland C++ for Windows IDEs
easier. See page 29 for information about the Native option.
Which command set you choose also determines which keys you
use within the editor, and, to some extent, how the editor works.
See more about using command sets in the editor in Appendix B.
Borland C++ for Windows handles project management just as
the Borland C++ DOS IDE does. See page 36 for information
about configuration, project, and desktop files.
Borland C++ for Windows has a SpeedBar you can use to quickly
choose menu commands and other actions with your mouse. The
first time you start Borland C++ for Windows, the SpeedBar is a
horizontal grouping of buttons just under the menu bar. You can
use it as it is, change it to a vertical bar that appears on the left
side of the Borland C++ for Windows desktop window, or change
it to a pop-up palette you can move anywhere on your screen.
You can also turn it off. To reconfigure the SpeedBar, choose
Options I Environment I Desktop, and select the option you want.
The buttons on the SpeedBar represent menu commands. They
are shortcuts for your mouse, just as certain key combinations are
shortcuts when you use your keyboard. To choose a command,
click a button with your mouse. If you click the File I Open button,
for example, Borland C++ for Windows responds just as if you
chose the Open command on the File menu.
The SpeedBar is context sensitive: Which buttons appear on it and
whether they're enabled or dimmed depend on which window is
active: the Borland C++ for Windows desktop window, an edit
window, the Project window, or the Message window. Some
buttons always appear.
41
Global buttons These buttons always appear, regardless of which type of window
is active: .
Help Open a file Make
Desktop window
Exit Borland C++ for Windows
Edit windows
Save file Paste from Clipboard
Search for text Undo
Search again Compile
Cut to Clipboard View include files
Copy to Clipboard
Project window
Compile View include files
Edit source file Add item to project
42 Borland C++ User's Guide
Message window
Chapter 2, IDE basics
Delete item from project
~
~
g
Local Options
Compile Edit source file View file with
error
. Some of the buttons on the SpeedBar are occasionally dimmed,
just as some of the menu commands are. This means that, in the
current context, the command the button represents is not
available. For example, the Paste from Clipboard button will be
dimmed if there is nothing in your Clipboard.
43
44 Borland C++ User's Guide
c H A
p
T E R
3
Menus and options reference
This chapter provides a reference to each menu option in the IDE.
Its arranged in the order that the menus appear on the screen. For
information on starting and exiting the IDE, using the IDE
command-line options, and general information on how the IDE
works, see Chapter 2.
Next to some of the menu option descriptions in this reference
you'll see keyboard shortcuts, or hot keys. If a commanq set
appears above the hot key, the hot key is valid only in that
command set. If no command set appears, the hot key works in
both command sets. For example,
CUA this means Alt+F4 is a hot key in the CVA command set,
[][)ffiJ
Alternate this means Alt+X is a hot key in the Alternate command set,
[][)0
@@ ~ and this means Ctrl+lns is a hot key in both command sets.
If you are also using Borland C++ for Windows, you'll find the
IDE very similar to the Borland C++ DOS IDE. Throughout this
menu reference, we've noted the major differences between the
two IDEs:
Borland C++ DOS IDE only _ This note indicates the feature occurs only in Borland C++ .
The Windows icon indicates the discussion is relevant only to
Borland C++ for Windows.
Chapter 3, Menus and options reference 45
If neither of these items appear next to the text, the text is
relevant to both IDEs.
- (System) menu
Borland C++ DOS IDE only
[lli] I Spacebar I
The:: menu appears on the far left of the menu bar. AIt+Spacebar is
the fastest way to get there. When you pull down this menu, you
see the Repaint Desktop command and the names of programs
you've installed with the Options I Transfer command.
Borland C++ for Windows has a Control menu on the far left of
the Title bar. Alt+Spacebaris the shortcut key. The Control menu
primarily lets you manage windows through menu commands
instead of using a mouse. It is the standard Windows Control
menu.
Repaint Desktop
46
Borland C++ DOS IDE only Choose:: I Repaint Desktop to have Borland C++ redraw the
screen. You may need to do this, for example, if a memory-
resident program has left stray characters on the screen, or
possibly if you have screen-swapping turned off (Options I
Debugger and you've selected None for the Display swapping
option) and you're stepping through a program.
Transfer items
Borland C++ DOS IDE only A program that appears here on the:: menu can be run directly
from the IDE. You install programs here with the Options I
Transfer command. To run one of these programs, choose its
name from the:: menu.
If you have more than one program installed with the same
shortcut letter on this menu, the first program listed with that
shortcut will be selected. You can select the second item by
clicking it or by using the arrow keys to move to it and then
pressing Enter.
Borland C++ User's Guide
File menu
New
Open
The File menu lets you open and create program files in edit
windows. The menu also lets you save your changes, perform
other file functions, and quit the IDE.
File
The File I New command lets you open a new edit window with
the default name NONAMExx.CPP (the xx stands for a number
from 00 to 31). These NONAME files are used as a temporary edit
buffer; the IDE prompts you to name a NONAME file when you
save it.
Alternate The File I Open command displays a file-selection dialog box for
[fl] you to select a program file to open in an edit window. Here is
what the box looks like:
Figure 3.1
The Open a File dialog box
-. - -.
~ ~ ~ - ;..: .f;-
+- TODODLGS. CPP
TODOLIST .CPP
TODOWIN.CPP
VCIRC.CPP
VPOINT .CPP
WHELLO.CPP
STARTUP\
The dialog box contains an input box, a file list, buttons labeled
Open, Replace, Cancel, and Help, and an information panel that
describes the selected file. Now you can do any of these actions:
II Type in a full file name and choose Replace or Open. Open
loads the file into a new edit window. Replace saves the file in
the active window and replaces it with the contents of the
selected file. An edit window must be active if you choose
Replace .
Type in a file name with wildcards, which filters the file list to
match your specifications.
Chapter 3, Menus and options reference 47
File I Open
If you choose Replace
instead of Open, the
selected file replaces the fife
in the active edit window
instead of opening up a new
window.
Using the File list
box
In Borland C++, you can also
type a lowercase letter to
search for a fife name or an
uppercase letter to search
for a directory name.
Borland C++ DOS IDE only
48
Press J., to choose a file specification from a history list of file
specifications you've entered earlier .
View the contents of different directories by selecting a
directory name in the file list.
The input box lets you enter a file name explicitly or enter a file
name with standard DOS wildcards (* and ?) to filter the names
appearing in the history list box. If you enter the entire name and
press Enter, Borland C++ opens it. (If you enter a file name that
Borland C++ can't find, it automatically creates and opens a new
file with that name.)
If you press J., when the cursor is blinking in the input box, a
history list drops down below the box. This list displays the last
15 file names or file-name masks you've entered. Choose a name
from the list by double-clicking it or selecting it with the arrow
keys and pressing Enter.
Once you've typed in or selected the file you want, choose the
Open button (choose Cancel if you change your mind). You can
also just press Enter once the file is selected, or you can double-
click the file name in the file list.
The Borland C++ for Windows Open a File dialog box doesn't
have the Replace button; therefore, you can only open another
edit window rather than replace the contents of the file in the
window with the contents of another file.
The File list box displays all file names in the current directory
that match the specifications in the input box, displays the parent
directory, and displays all subdirectories. Click the list box or
press Tab until the list-box name is highlighted. You can now
press J., or i to select a file name, and then press Enter to open it.
You can also double-click any file name in the box to open it. You
might have to scroll the box to see all the names. If you have more
than one pane of names, you can also use ----7 and ~ .
The file information panel at the bottom of the Open a File dialog
box displays path name, file name, date, time, and size of the file
you've selected in the list box. As you scroll through the list box,
the panel is updated for each file.
Borland C++ User's Guide
Save
Alternate
rnJ
Save As
Figure 3.2
The Save File As dialog box
Save All
File I Save
The File I Save command saves the file in the active edit window
to disk. (This menu item is disabled if there's no active edit
window.) If the file has a default name (NONAMEOO.CPP, or the
like), the IDE opens the Save File As dialog box to let you rename
and save it in a different directory or on a different drive. This
dialog box is identical to the one opened for the Save As
command, described next.
The File I Save As command lets you save the file in the active edit
window under a different name, in a different directory, or on a
different drive. When you choose this command, you see the Save
File As dialog box:
~ TODODLGS.CPP
TODOLIST .CPP
TODOWIN.CPP
VCIRC.CPP
VPOINT.CPP
WHELLO.CPP
STARTUP\
Enter the new name, optionally with drive and directory, and
click or choose OK. All windows containing this file are updated
with the new name.
The File I Save All command works just like the Save command
except that it saves the contents of all modified files, not just the
file in the active edit window. This command is disabled if no edit
windows are open.
Chapter 3, Menus and options reference 49
File I Change Dir
Change Dir
Borland C++ DOS IDE only The File I Change Dir command lets you specify a drive and a
directory to make current. The current directory is the one
Borland C++ uses to save files and search for files. (When using
relative paths in Options I Directories, they are relative to this
current directory only.)
Here is what the Change Directory dialog box looks like:
Figure 3.3
The Change Directory dialog
box
50
There are two ways to change directories:
Type in the path of the new directory in the input box and press
Enter .
Choose the directory you want in the Directory tree (if you're
using the keyboard, press Enterto make it the current directory),
then choose OK or press Esc.
If you choose the OK button, your changes are made and the
dialog box is closed. If you choose the Chdir button, the Directory
Tree list box changes to the selected directory and displays the .
subdirectories of the currently highlighted directory (pressing
Enter or double-clicking on that entry gives you the same result). If
you change your mind about the directory you've picked and you
want to go back to the previous one (and you've yet to exit the
dialog box), choose the Revert button.
Opening a project in another directory automatically changes
directories, so you don't have to change directories before you
open another project.
Borland C++ User's Guide
Print
In the DOS IDE, you can also
print the contents of the
Output window.
Printer Setup
1BI
EJ
Use this option if you want to
change your printer setup
from its normal configuration.
DOS Shell
File I Print
The File I Print command lets you print the contents of the active
edit window or the Message window. This command is disabled
if the active window can't be printed.
The Printer Setup command displays a Windows dialog box you
can use to set up your printer. When you installed Windows on
your system, you probably also installed one or more printer
drivers so you could print from Windows. The Printer Setup
command lets you select which printer you want to use.
If you choose Setup in the Printer Setup dialog box, another
dialog box appears allowing you to select a paper size, specify a
particular font, and so forth. The options available depend on the
capabilities of your printer.
Borland C++ DOS IDE only The File I DOS Shell command lets you temporarily exit Borland
c++ to enter a DOS command or program. To return to Borland
C++, type EXIT and press Enter.
You may find when you're debugging that there's not enough
memory to execute this command. If that's the case, terminate the
debug session by choosing Run I Program Reset.
... Don't install any TSR programs (like SideKick) or print a file with
the DOS print command while you've shelled to DOS, because
memory may be misallocated.
In dual-monitor mode, the DOS command line appears on the
Borland C++ screen rather than the User Screen. This allows you
to switch to DOS without disturbing the output of your program.
You can also use the transfer items on the :: (System) menu to
quickly switch to another program without leaving Borland C++.
Chapter 3, Menus and options reference
51
File I Exit
Exit
eUA
@][E)
Alternate
@][]]
The File I Exit command exits the IDE and removes it from
memory. If you have made any changes you haven't saved, the
IDE asks if you want to save them before exiting.
Closed file listing
Edit menu
52
If you have opened files and then closed them, you'll see the last
five files listed at the bottom of the File menu. If you select the file
name on the menu, the file opens. When you work with many
open files, you can close some, then open them again quickly
using the list and reduce the clutter on your desktop.
The Edit menu lets you cut, copy, and paste text in edit windows.
If you make mistakes, you can undo changes and even reverse the
changes you've just undone. You can also open a Clipboard
window to view or edit its contents, and copy text from the
Message and Output windows.
Before you can use most of the commands on this menu, you need
to know about selecting text (because most editor actions apply to
selected text). Selecting text means highlighting it. You can select
text either with keyboard commands or with a mouse; the princi-
ple is the same even though the actions are different.
~ From the keyboard:
Press Shift while pressing any key that moves the cursor.
See page 195 in Appendix B for additional text selection
commands.
w.. With a mouse:
To select text with a mouse, drag the mouse pointer over the
desired text. If you need to continue the selection past a
Borland C++ User's Guide
Undo
em] I Backspace I
Undo can undo groups of
commands.
Redo
em] I Shift II Backspace I
window's edge, just drag off the side and the window
automatically scrolls.
II To select a single word, double-click it.
a To extend or reduce the selection, Shift-click anywhere in the
document (that is, hold Shift and click).
Edit
Once you selected text, the Cut and Copy commands in the Edit
menu become available.
The Clipboard is the magic behind cutting and pasting. It's a
special window that holds text you cut or copied, so you can
paste it elsewhere. The Clipboard works in close concert with the
commands in the Edit menu.
Here's an explanation of each command in the Edit menu.
The Edit I Undo command restores the file in the current window
to the way it was before the most recent edit or cursor movement.
If you continue to choose Undo, the editor continues to reverse
actions until your file returns to the state it was in when you
began your current editing session.
Undo inserts any characters you deleted, deletes any characters
you inserted, replaces any characters you overwrote, and moves
your cursor back to a prior position. If you undo a block
operation, your file appears as it did before you executed the
block operation.
Undo doesn't change an option setting that affects more than one
window. For example, if you use the Ins key to change from Insert
to Overwrite mode, then choose Undo, the editor won't change
back to Insert mode.
The Group Undo option in the Editor Options dialog box
(Options I Environment I Editor) affects Undo and Redo. See page
116 for information on Group Undo.
The Edit I Redo command reverses the effect of the most recent
Undo command. The Redo command only has an effect
immediately after an Undo command or after another Redo
command. A series of Redo commands reverses the effects of a
series of Undo commands.
Chapter 3, Menus and options reference 53
EditlCut
Cut
I Shift 1[Qill
Copy
[ @ ~
Borland C++ DOS IDE only
54
Paste
I Shift I ~
Clear
[@[Qill
The Edit I Cut command removes the selected text from your
document and places the text in the Clipboard. You can then
paste that text into any other document (or somewhere else in the
same document) by choosing Paste. The text remains selected in
the Clipboard so that you can paste the same text many times.
The Edit I Copy command leaves the selected text intact but places
an exact copy of it in the Clipboard. You can then paste that text
into any other document by choosing Paste.
If the Output or Message window is the active window when you
select Edit I Copy, the entire contents of the window buffer
(including any invisible portion) are copied to the Clipboard.
You can also copy text from a Help window: With the keyboard,
use Shift and the arrow keys; with the mouse, click and drag the
text you want to copy.
To copy text from a Help window in Borland C++ for Windows,
display the text you want to copy, then select Edit I Copy. The
entire contents of the window are copied to the Clipboard.
The Edit I Paste command inserts text from the Clipboard into the
current edit window at the cursor position. The text that is pasted
is the currently marked block in the Clipboard window.
The Edit I Clear command removes the selected text but does not
put it into the Clipboard. This means you can't paste the text as
you could if you had chosen Cut or Copy. The cleared text is not
retrievable unless you use the Edit I Undo command. Clear is
useful if you want to delete text but you don't want to overwrite
text being held in the Clipboard. You can clear the Clipboard itself
by selecting all the text in the Clipboard, then choosing Edit I
Clear.
Borland C++ User's Guide
Copy Example
Borland C++ DOS IDE only
Show Clipboard
Borland C++ DOS IDE only
You can save the Clipboard
contents across sessions in
Borland C++. Choose
Options I Environment I
Desktop and select the
Clipboard option.
Edit I Copy Example
The Edit I Copy Example command copies the preselected
example text in the current Help window to the Clipboard. The
examples are already predefined as blocks you can paste, so you
don't need to mark the example.
To copy a Help example in Borland C++ for Windows, follow
these steps:
1. Display the example you want to copy in the Help window.
2. Choose Edit I Copy. All the text in the Help window is copied
to the Clipboard.
3. Make the window you want the example copied to the active
window.
4. Choose Edit I Paste.
The Edit I Show Clipboard command opens the Clipboard
window, which stores the text you cut and copy from other
windows. The text that's currently selected (highlighted) is the
text Borland C++ uses when you choose Paste.
You can think of the Clipboard window as a history list of your
cuts and copies. You can edit the Clipboard so that the text you
paste is precisely the text you want. Borland C++ uses whatever
text is selected in the Clipboard when you choose Paste.
The Clipboard window is just like other edit windows; you can
move it, resize it, and scroll and edit its contents. The only
difference you'll find in the Clipboard window is when you
choose to cut or copy text. When you select text in the Clipboard
window and choose Cut or Copy, the selected text immediately
appears at the bottom of the window. (Remember, any text you
cut or copy is. appended to the end of the Clipboard and
highlighted-so you can paste it later.)
The Edit I Show Clipboard option doesn't appear in the Borland
C++ for Windows IDE. Of course, you can display the Clipboard
at any time using the Windows Clipboard Viewer.
Chapter 3, Menus and options reference 55
Search
Search menu
56
Find
@!ill [9J [J
Figure 3.4
The Find Text dialog box
You can set up your right
mouse button to Find Text.
Choose Options I
Environment I Mouse and
select the Search option.
! [X] Case sensitive!
! [ ] Whole words OnlY!
I[ ] Regular expression!
The Search menu lets you search for text, function declarations,
and error locations in your files.
The Search I Find command displays the Find Text dialog box,
which lets you type in the text you want to search for and set
options that affect the search.
The Find Text dialog box contains several buttons and check
boxes:
Check the Case Sensitive box if you do want the IDE to
differentiate uppercase from lowercase.
Check the Whole Words Only box if you want the IDE to search
for words only. (That is, the string must have punctuation or
space characters on both sides.)
Check the Regular Expression box if you want the IDE to
recognize GREP-like wildcards in the search string. The wildcards
are '\ $, ., *, +, [], and \. Here's what they mean:
A
$
*
A circumflex at the start of the string matches the start of a
line.
A dollar sign at the end of the expression matches the end
of a line.
A period matches any character.
A character followed by an asterisk matches any number of
occurrences (including zero) of that character. For example,
bo* matches bot, b, boo, and also be.
Borland C++ User's Guide
To search for "J," include it as
the first character in
brackets. For example,
"( Jab)" will search for "J,"
"a," and "b."
Direction
(e) Forward
( ) Backward
Scope
(e) Global
( ) Selected text
Origin
(e) From cursor
( ) Entire scope
Search I Find
+ A character followed by a plus sign matches any number of
occurrences (but not zero) of that character. For example,
bo+ matches bot and boo, but not be or b.
[ ]
[ - ]
Characters in brackets match anyone character that
appears in the brackets but no others. For example [botl
matches b, 0, or t.
A circumflex at the start of the string in brackets means not.
Hence, [/\botl matches any characters except b, 0, or t.
A hyphen within the brackets signifies a range of
characters. For example, [b-ol matches any character from b
througho. .
\ A backslash before a wildcard character tells Borland C++
to treat that character literally, not as a wildcard. For
. example, \ /\ matches /\ and does not look for the start of a
line.
Enter the string in the input box and choose OK to begin the
search, or choose Cancel to not do it. If you want to enter a string
that you searched for previously, press J, (or Alt+J, in Borland
C++ for Windows) to show a history list to choose from.
You can also pick up the word your cursor is currently on in the
edit window and use it in the Find Text box by simply invoking
Find from the Search menu. In the DOS IDE, you can take
additional characters from the text by pressing ~ .
Choose from the Direction radio buttons to decide which
direction you want the IDE to search-starting from the origin
'(which you can set with the Origin radio buttons).
Choose from the Scope buttons to determine how much of the file
to search in. You can search the entire file (Global) or only the text
you've selected.
Choose from the Origin buttons to determine where the search
begins. When Entire Scope is chosen, the Direction radio buttons
determine whether the search starts at the beginning or the end of
the scope. You choose the range of scope with the Scope radio
buttons.
Chapter 3, Menus and options reference 57
Search I Replace
Replace
Alternate
@!D[9][E]
Figure 3.5
The Replace Text dialog box
58
Search Again
eVA
@]
Alternate
@!D[IJ
The Search I Replace command displays a dialog box that lets you
type in the text you want to search for and the text you want to
replace it with.
The Replace Text dialog box contains several radio buttons and
check boxes-many of which are identical to the Find Text dialog
box, discussed previously. An additional checkbox, Prompt on
Replace, controls whether you're prompted for each change.
Enter the search string and the replacement string in the input
boxes and choose OK or Change All to begin the search, or choose
Cancel to not do it. If you want to enter a string you used
previously, press J, (or Alt+J, in Borland C++ for Windows) to
show a history list to choose from.
If the IDE finds the specified text and Prompt on Replace is on, it
asks you if you want to make the replacement. If you choose OK,
it will find and replace only the first instance of the search item. If
you choose Change All, it replaces all occurrences found, as
defined by Direction, Scope, and Origin.
The Search I Search Again command repeats the last Find or
Replace command. All settings you made in the last dialog box
used (Find or Replace) remain in effect when you choose Search
Again.
Borland C++ User's Guide
Go to Line
Number
Previous Error
@J[ITJ
Next Error
@Jffi]
Locate Function
Search I Go to Line Number
The Search I Go to Line Number command prompts you for the
line number you want to find.
The IDE displays the current line number and column number in
the lower left corner of every edit window.
The Search I Previous Error command moves the cursor to the
location of the previous error or warning message. This command
. is available only if there are messages in the Message window
that have associated line numbers.
The Search I Next Error command moves the cursor to the location
of the next error or warning message. This command is available
only if there are messages in the Message window that have
associated line numbers.
Borland C++ DOS IDE only The Search I Locate Function command displays a dialog box for
you to enter the name of a function to search for. This command is
available only during a debugging session.
Run menu.
Run
@ill[[]
Enter the name of a function or press J, to choose a name from the
history list. As opposed to the find command, this command
finds the declaration of the function, not instances of its use.
The Run menu's commands run your program, start and end
debugging sessions in Borland C++, and start Turbo Debugger for
Windows in the Borland C++ for Windows IDE.
The Run I Run command runs your program, using any
arguments you pass to it with the Run I Arguments command. If
the source code has been modified since the last compilation, it
Chapter 3, Menus and options reference 59
RunlRun
Borland C++ DOS IDE only
If you want to have all
Borland C++ S features
available, set Source
Debugging to On.
Source code the same
also invokes the Project Manager to recompile and link your pro-
gram. (The Project Manager is a program-building tool
incorporated into the IDE; see Chapter 3, "The Project menu," for
more on this feature.)
If you're using Borland C++ for Windows and aren't planning to
debug your program with Turbo Debugger for Windows, you can
compile and link it with Source Debugging unchecked in the
Options I Linker dialog box. Your program will link faster.
The rest of this discussion about Run I Run applies only to the
Borland C++ DOS IDE.
If you don't want to debug your program in Borland C++, you
can compile and link it with the Source Debugging radio button
set to None (which makes your program link faster) in the
Options I Debugger dialog box. If you compile your program with
Source Debugging set to On, the resulting executable code
contains debugging information that affects the behavior of the
Run I Run command in the following ways:
If you have not modified your source code since the last
compilation,
the Run I Run command causes your program to run to the next
breakpoint, or to the end if no breakpoints have been set.
Source code modified If you have modified your source code since the last compilation,
and
60
if you're already stepping through your program using the
Run I Step Over or Run I Trace Into commands, Run I Run asks if
you want to rebuild your program:
If you answer yes, the Project Manager recompiles and links
your program, then sets it to run from the beginning .
If you answer no, your program runs to the next breakpoint,
or to the end if no breakpoints are set.
if you are not in an active debugging session, the Project
Manager remakes your program, then sets it to run from the
beginning.
Pressing Ctrl+Break causes the IDE to stop execution on the next
source line in your program. If the IDE is unable to find a source
Borland C++ User's Guide
RunlRun
line, a second Ctrl+Break terminates the program and returns you to
the IDE.
~ . You can't run or debug Windows applications within the DOS
IDE. If you try to do so, an error dialog box appears.
Program Reset
Borland C++ DOS IDE only
Go to Cursor
Borland C++ DOS IDE only
Alternate
em
Trace Into
Borland C++ DOS IDE only
The Run I Program Reset command stops the current debugging
session, releases memory your program has allocated, and closes
any open files your program was using. Use this command when
you want to cancel a debugging session, or if there's not enough
memory to run transfer programs or invoke a DOS shell.
The Run I Go to Cursor command runs your program from the
beginning of the program (or the last executed statement if you're
in the middle of a debugging session) to the line the cursor is on
in the current edit window. If the cursor is at a line that does not
contain an executable statement, the command displays a
warning.
Go to Cursor does not set a permanent breakpoint, but it does
allow the program to stop at a permanent breakpoint if it
encounters one before the line the cursor is on. If this occurs, you
must move the cursor back to where it was and choose the Go to
Cursor command again.
Use Go to Cursor to advance tht:; run bar (the highlighted line of
code that represents the next statement to be executed) to the part
of your program you want to debug. If you want your program to
stop at a certain statement every time it reaches that point, set a
breakpoint on that line.
If you position the cursor on a line of code that is not executed,
your program will run to the next breakpoint or to the end if no
breakpoints are encountered. You can always use Ctrl+Break to stop
a running program.
The Run I Trace Into command runs your program statement-by-
statement. If you Trace Into a function call, the run bar stops on
the first line of the function instead of executing the function as a
single step (see Run I Step Over). If a statement contains no calls to
Chapter 3, Menus and options reference 61
Run I Trace Into
Step Over
Borland C++ DOS IDE only
62
functions accessible to the debugger, Trace Into stops at the next
executable statement.
Use the Trace Into command to enter a function called by the
function you are now debugging. The next section illustrates the
differences between the Trace Into and Step Over commands.
If the statement contains a call to a function accessible to the
debugger, Trace Into halts at the beginning of the function's
definition. Subsequent Trace Into or Step Over commands run the
statements in the function's definition. When the debugger leaves
the function, it resumes evaluating the statement that contains the
call; for example,
if (funcl() && func2())
do_sornething();
When the run bar is on the if statement, F7 (Trace Into) traces into
func1; when the run bar is on the return in func1, F7 traces into
func2. With the run bar on. the if statement, FB (Step Over) steps
over func2 and stops on do_something.
The Trace Into command recognizes only functions defined in a
source file compiled with these two options on:
In the Advanced Code Generation dialog box (Options I
Compiler), Debug Info in OBJs must be checked .
In the Options I Debugger dialog box, Source Debugging must
be set to On.
The Run I Step Over command executes the next statement in the
current function. It does not trace into calls to lower-level
functions, even if they are accessible to the debugger.
Use Step Over to run the function you are now debugging, one
statement at a time without branching off into other functions.
Here is an example of the difference between Run I Trace Into and
Run I Step Over. These are the first 12 lines of a program loaded
into an edit window:
int findit(void)
{
return(2) ;
1* Line 1 *1
Borland C++ User's Guide
Arguments
void main(void)
{
int i, j i
/* Line 6 */
i = findit()i /* Line 10 */
printf("%d\n", i) i /* Line 11 */
j = 0 i /* Line 12 * /
Run I Step Over
findit is a user-defined function in a module that has been
compiled with debugging information. Suppose the run bar is on
line 10 of your program. To position the run bar on line 10, place
the cursor on line 10 and either press F4 or select Run I Go to
Cursor .
.. If you now choose Run I Trace Into, the run bar moves to the
first line of the findit function (line 1 of your program), allowing
you to step through the function .
.. If you choose Run I Step Over, the findit function executes and
the run bar moves to line 11.
If the run bar had been on line 11 of your program, it would have
made no difference which command you chose; Run I Trace Into
and Run I Step Over both would have executed the printf function
and moved the run bar to line 12. This is because the printf
function does not contain debug information.
The Run I Arguments command allows you to give your running
programs command-line arguments exactly as if you had typed
them on the DOS command line. DOS redirection commands are
ignored.
When you choose this command, a dialog box appears with a
single input box. You only need to enter the arguments here, not
the program name. Arguments take effect when your program
starts.
Borland C++ DOS IDE only If you are already debugging and want to change the arguments,
select Program Reset and Run I Run to start the program with the
new arguments.
Chapter 3, Menus and options reference 63
Run I Debugger
Debugger
10 The Run I Debugger command starts Turbo Debugger for
~ Windows so you can debug your program. Borland C++ for
Windows tells Turbo Debugger which program to debug. Before
you can use Turbo Debugger for Windows to debug your
program you must:
Debugger
Options
1. Choose Options I Compiler. In the Advanced Code Generation
dialog box, check the Debug Info in OBJs option.
2. Choose Options I Linker and set Source Debugging on.
The Run I Debugger Options comlnand lets you pass arguments to
Turbo Debugger for Windows when you choose the Run I
Debugger command. See the Turbo Debugger User's Guide for a
description of all options.
Compile menu
64
Compile
cmcm
Use the commands on the Compile menu to compile the program
in the active window or to make or build your project. To use the
Compile, Make, Build, and Link commands, you must have a file
open in an active edit window or a project defined.
The Compile I Compile command compiles the file in the active
edit window. If the Project or Message Window is active,
Compile I Compile compiles the highlighted file.
When the compiler is compiling, a status box displays the
compilation progress and results. When compilation is complete,
press any key to remove this box. In Borland C++ for Windows,
press Enter or choose OK. If any errors or warnings occurred, the
Message window becomes active and displays and, highlights the
first error.
Borland C++ User's Guide
Make
([]
If no project is open, the IDE
uses the options in the
default project file
(TCDEFDPR for the DOS IDE
and TCDEFW.DPR for the
Windows IDE).
Link
Build
Compile I Make
The Compile I Make command invokes the Project Manager to
compile and link your source code to the target executable or
library file.
Compile I Make rebuilds only the files that aren't current.
The .EXE file name listed is derived from one of two names in the
following order:
If a project is open, the .EXE is named after the .PR} file.
If no project is open, the .EXE is named after the file in the
active edit window.
The Compile I Link command takes the files defined in the current
project file or the defaults and links them.
This command is similar to Compile I Make except it rebuilds all
the files in the project whether or not they are current. It performs
the following steps:
1. It deletes the appropriate precompiled header (.SYM) file, if it
exists.
2. It deletes any cached auto dependency information in the
project.
3. It sets the date and time of all the project's .OB} files to zero.
4. Finally, it does a make.
If you abort a Build command by pressing Ctrl+Break in the DOS
IDE, pressing Esc or choosing Cancel in Borland C++ for
Windows, or you get errors that stop the build, you can pick up
where it left off simply by choosing Compile I Make.
Chapter 3, Menus and options reference 65
Compile I Information
Information
Table 3.1
Information settings
You'll see only some of these
settings in Borland C++ for
Windows.
Remove
Messages
Debug menu
Borland C++ DOS IDE only
66
The Compile I Information command displays a dialog box with
information on the current file or project. The information is for
display only; you can't change it in the dialog box. The following
table tells you what each line in the File Information dialog box
means and where you can go to change the settings.
Setting
Current directory
Current file
Expanded memory in use
Lines compiled
Total warnings
Total errors
Total time
Program loaded
Program exit code
Available memory
Meaning
The default directory.
File in the active window.
Amount of expanded memory reserved by
Borland C++.
Number of lines compiled.
Number of warnings issued.
Number of errors generated.
Amount of time your program has run
(debugger only).
Debugging status.
DOS termination code of last terminated
program.
Amount of memory available to Borland C++
in bytes.
The Compile I Remove Messages command removes all messages
from the Message window.
The Debug menu appears in the Borland C++ DOS IDE only. The
commands on the Debug menu control all the features of the inte-
grated debugger. You specify if debugging information is
generated in the Options I Debugger dialog box.
You can't run or debug Windows applications within the Borland
C++ IDE. If you try to do so, you'll get an error dialog box to that
effect. You must run them under Microsoft Windows and use
Turbo Debugger for Windows.
To debug applications in the Borland C++ for Windows IDE, use
Turbo Debugger for Windows. Start Turbo Debugger with the
Run I Debugger command.
Borland C++ User's Guide
Debug
Qualifying
expressions When a data element you wish to examine (in a Watch or
Inspector window, for example) isn't currently in scope, you'll
need to qualify the name so the integrated debugger can find it.
Three common cases and their qualified names:
Table 3.2
Expression qualifiers
To examine ...
Static variables in another module
Local variables in a global function
Local variables in a static function
Use this format
.module.variable
function. variable
.module. function. variable
For example, suppose your program has two modules:
FIRSTMOD and MODULE2:
II FIRSTMOD.CPP
#include <iostream.h>
void rnyFunc{void);
int a = 1;
int rnain(void)
{
int b = 2;
rnyFunc{);
cout a;
II MODULE2.CPP
#include <iostream.h>
static int e = 3;
static void localFunc{void)
{
int d = 4;
cout "End of the road" endl;
void rnyFunc{void)
{
int c = 5;
localFunc{);
Chapter 3, Menus and options reference
67
Debug
68
Inspect
Alternate
~ c m
You can set up your right
mouse button to inspect.
Choose Options I
Environment I Mouse and
select the Inspect option.
Some samples of expressions:
To examine ...
Global variable a
Local variable b in main
Local variable c in myFunc
Local variable d in static localFunc
Static variable e in module MODULE2
Use this expression
a
main.b
myFunc.c
.module2.1ocalFunc.d
.module2.e
The need for qualifying an expression depends on the current
scope. If the program is running inside main, there's no need to
qualify b with the function name main. Likewise, if the program is
running inside MODULE2, it's not necessary to qualify e with the
module name.
You can't examine auto (local) variables in an inactive scope.
Since myFunc calls localFunc, you can watch myFunc's local
variables when inside of localFunc. However, once myFunc
returns to main, you can no longer view its local variables, since
local variables are discarded when the function returns to its
caller.
The Debug I Inspect command opens an Inspector window that
lets you examine and modify values in a data element. The type of
element you're inspecting determines the type of information
presented in the window. There are two ways to open an
Inspector window:
You can position the cursor on the data element you want to
inspect, then press Alt+F4 (while in the Alternate command set).
You can also choose Debug I Inspect to bring up the Inspector
dialog box, then type in the variable or expression you want to
inspect. Alternatively, you can position the cursor on an
expression, select Debug I Inspect, and while in this dialog box,
press -7 to bring in more of the expression. Press Enter to
inspect it.
To close an Inspector window, make sure the window is active
(topmost) and press Esc or choose Window I Close.
Here are some additional inspection operations you can perform:
Subinspecting: Once you're in an Inspector window, you can
inspect certain elements to isolate the view. When an inspector
Borland C++ User's Guide
Ordinal Inspector
windows
Pointer Inspector
windows
Debug I Inspect
item is inspectable, the status line displays the message".J
Inspect." To sub inspect an item, you move the inspect bar to the
desired item and press Enter.
III Modifying inspector items: When an inspector item can be
modified, the status line displays" Alt+M Modify Field." Move
the cursor to the desired item and press Alt+M; a dialog box will
prompt you for the new value.
E:I Inspect range: When you are inspecting certain elements, you
can change the range of values displayed. For example, you can
range-inspect pointer variables to tell Borland C++ how many
elements the pointer points to. You can range-inspect an
inspector when the status line displays the message "Set index
range" and with the command Alt+l.
The following sections briefly describe the eight types of Inspector
windows.
Ordinal Inspector windows show you the value of simple data
items, such as
char x = 4;
unsigned long y = 123456L;
These Inspector windows only have a single line of information
following the top line (which usually displays the address of the
variable, though it may display the word" constant" or have other
information in it, depending on what you're inspecting). The type
of the scalar variable (char, unsigned long, and so forth) appears
to the left, and to the right appears its present value. The value
can be displayed as decimal, hex, or both. It's usually displayed
first in decimal, with the hex values in parentheses (using the
standard C hex prefix of Ox).
If the variable being displayed is of type char, the character
equivalent is also displayed. If the present value does not have a
printing character equivalent, the backslash (\) followed by a hex
value displays the character value. This character value appears
before the decimal or hex values. .
Pointer Inspector windows show you the value of data items that
point to other data items,such as
char *p = "abc";
int *ip = 0;
int **ipp = &ip;
Chapter 3, Menus and options reference 69
Debug I Inspect
70
Array Inspector
windows
Pointer Inspector windows usua}ly have a top line that contains
the address of the pointer variable and the address being pointed
to, followed by a single line of information.
To the left appears [0], indicating the first member of an array. To
the right appears the value of the item being pointed to. If the
value is a complex data item such as a structure or an array, as
much of it as possible is displayed, with the values enclosed in
braces ({ and }).
If the pointer is of type char and appears to be pointing to a null-
terminated character string, more information appears, showing
the value of each item in the character array. To the left in each
line appears the array index ([1], [2], and so on), and the value
appears to the right as it would in a scalar Inspector window. In
this case, the entire string is also displayed on the top line, along
with the address of the pointer variable and the address of the
string that it points to.
Array Inspector windows show you the value of arrays of data
items, such as
long thread [3] [4] [5] ;
char message[] = "eat these words";
There is a line for each member of the array. To the left on each
line appears the array index of the item. To the right appears the
value of the item being pointed to. If the value is a complex data
item such as a structure or array, as much of it as possible is
displayed, with the values enclosed in braces ({ and n.
Structure and Union Structure and Union Inspector windows show you the value of
Inspector windows the members in your structure, class, and union data items. For
example,
struct date {
int year;
char month;
char day;
today;
union {
int small;
long large;
} holder;
Bor/and C++ User's Guide
Function Inspector
windows
Class Inspector
windows
Constant Inspector
window
Type Inspector window
Evaluate/Modify
Alternate
@ill[ill
Debug I Inspect
Structures and unions appear the same in Inspector windows.
These Inspector windows have as many items after the address as
there are members in the structure or union. Each item shows the
name of the member on the left and its value on the right,
displayed in a format appropriate to its data type.
Function Inspector windows show the return type of the function
at the bottom of the inspector. Each parameter that a function is
called with appears after the memory address at the top of the list.
Function Inspector windows give you information about the
calling parameters, return data type, and calling conventions for a
function.
The Class (or object) Inspector window lets you inspect the details
of a class variable. The window displays names and values for
members and methods defined by the class.
The window can be divided into two panes horizontally, with the
top pane listing the data fields or members of the class, and the
bottom pane listing the member function names and the function
addresses. Press Tab to move between the two panes.
If the highlighted data field is a class or a pointer to a class,
pressing Enter opens another Class Inspector window for the
highlighted type. In this way, you can quickly inspect complex
nested structures of classes with a minimum of keystrokes.
Constant Inspector windows are much like Ordinal Inspector
windows, but they have no address and can never be modified.
The Type Inspector window lets you examine a type. There is a
Type Inspector window for each kind of instance inspector. The
difference between them is that instance inspectors display the
value of a field and Type inspectors display the type of a field.
The Debug I Evaluate/Modify command evaluates a variable or
expression, displays its value, and if appropriate, lets you modify
the value. The command opens a dialog box containing three
fields: the Expression field, the Result field, and the New Value
field.
Chapter 3, Menus and options reference 71
Debug I Evaluate/Modify
The Evaluate button is the
default button: when you
tab to the New Value field,
the Modify button becomes
the default.
72
The Expression field shows a default expression consisting of the
word at the cursor in the Edit window. You can evaluate the
default expression by pressing Enter, or you can edit or replace it
first. You can also press ---7 to extend the default expression by
copying additional characters from the Edit window.
You can evaluate any valid C expression that doesn't contain
function calls
symbols or macros defined with #define
local or static variables not in the scope of the function being
executed
If the debugger can evaluate the expression, it displays the value
in the Result field. If the expression refers to a variable or simple
data element, you can move the cursor to the New Value field and
enter an expression as the new value.
Press Esc to close the dialog box. If you've changed the contents of
the New Value field but do not select Modify, the debugger
ignores the New Value field when you close the dialog box.
Use a repeat expression to display the values of consecutive data
elements. For example, for an array of integers named xarray,
xarray [0 1 , 5 displays five consecutive integers in decimal
xarray [0 1 , 5x displays five consecutive integers in hexadecimal
An expression used with a repeat count must represent a single
data element. The debugger views the data element as the first
element of an array if it isn't a pointer, or as a pointer to an array
. if it is.
The Debug I Evaluate/Modify command displays each type of
value in an appropriate format. For example, it displays an int as
an integer in base 10 (decimal), and a.n array as a pointer in base
16 (hexadecimal). To get a d i f f e r e ~ t display format, precede the
expression with a comma followed by one of the format specifiers
shown in Table 3.3 on page 74. .
Borland C++ User's Guide
Call Stack
Alternate
C9ill[ill
Compiling with Standard
Stack Frame unchecked (0 I
C I Entry/Exit Code) causes
some functions to be omitted
from the call stack. For more
details, see page 92.
Debug I Call Stack
The Debug I Call Stack command opens a dialog box containing
the call stack. The Call Stack window shows the sequence of
functions your program called to reach the function now running.
At the bottom of the stack is main; at the top is the function that's
now running.
Each entry on the stack displays the name of the function called
and the values of the parameters passed to it.
Initially the entry at the top of the stack is highlighted. To display
the current line of any other function on the call stack, select that
function's name and press Enter. The cursor moves to the line
containing the call to the function next above it on the stack.
For example, suppose the call stack looked like this:
func2 ()
func1 ()
main()
This tells you that main called func1, and func1 called func2. If
you wanted to see the line of func1 that called func2, you could
select func1 in the call stack and press Enter. The code for func1
would appear in the Edit window, with the cursor positioned on
the call to func2.
To return to the current line of the function now being run (that
is, to the run position), select the topmost function in the call stack
and press Enter.
Chapter 3, Menus and options reference
73
Debug I Call Stack
Table 3.3: Format specifiers recognized in debugger expressions
Character Function
C Character. Shows special display characters for control characters (ASCII 0 through 31);
by default, such characters are shown using the appropriate C escape sequences (\n, \t,
and so on). Affects characters and strings.
S String. Shows control characters (ASCII 0 through 31) as ASCII values using the
appropriate C escape sequences. Since this is the default character- and string-display
format, the S specifier is only useful in conjunction with the M specifier.
D Decimal. Shows all integer values in decimal. Affects simple integer expressions as well as
arrays and structures containing integers.
H or X Hexadecimal. Shows all integer values in hexadecimal with the Ox prefix. Affects simple
integer expressions as well as arrays and structures containing integers.
Fn Floating point. Shows n significant digits (n is an integer between 2 and 18). The default
value is 7. Affects only floating-point values.
M Memory dump. Displays a memory dump, starting with the address of the indicated
expression. The expression must be a construct that would be valid on the left side of an
assignment statement, that is, a construct that denotes a memory address; otherwise, the
M specifier is ignored.
By default, each byte of the variable is shown as two hex digits. Adding a D specifier with
the M causes the bytes to be displayed in decimal. Adding an H or X specifier causes the
bytes to be displayed in hex. An S or a C specifier causes the variable to be displayed as a
string (with or without special characters). The default number of bytes displayed
corresponds to the size of the variable, but a repeat count can be used to specify an exact
number of bytes.
P Pointer. Displays pointers in seg:ofs format with additional information about the address
pointed to, rather than the default hardware-oriented seg:ofs format. Specifically, it tells
you the region of memory in which the segment is located, and the name of the variable at
the offset address, if appropriate. The memory regions are as follows:
R
74
Memory region
OOOO:OOOO-OOOO:03FF
OOOO:0400-0000:04FF
OOOO:0500-Borland C++
Borland C++-User Program PSP
User Program PSP
User Program-top of RAM
AOOO:OOOO-AFFF:FFFF
BOOO:OOOO-B7FF:FFFF
B800:0000-BFFF:FFFF
COOO:OOOO-EFFF:FFFF
FOOO:OOOO-FFFF:FFFF
Evaluate message
Interrupt vector table
BIOS data area
MS-DOSjTSRs
Borland C++
User Process PSP
Name of a static user variable if its address falls inside the
variable's allocated memory; otherwise nothing
EGAjVGA Video RAM
Monochrome Display RAM
Color Display RAM
EMS Pagesj Adaptor BIOS ROMs
BIOS ROMs
Structure/Union. Displays field names as well as values, such as {X:l, Y:I0, 2:5}. Affects
only structures and unions.
Borland C++ User's Guide
Watches
Add Watch
eUA
[QillffiJ
Alternate
[Qill[IT]
Debug I Watches
The Debug I Watches command opens a pop-up menu of
commands that control the use of watch expressions. Watch
expressions can be saved across sessions; see Options I
Environment I Desktop. The following sections describe the
commands in this pop-up menu.
The Add Watch command inserts a watch expression into the
Watch window.
When you choose this command, the debugger opens a dialog
box and prompts you to enter a watch expression. The default
expression is the word at the cursor in the current Edit window.
There's also a history list available if you want to quickly enter an
expression you've used before.
When you type a valid expression and press Enter or click OK, the
debugger adds the expression and its current value to the Watch
window. If the Watch window is the active window, you can
insert a new watch expression by pressing Ins.
Delete Watch The Delete Watch command deletes the current watch expression
from the Watch window. To delete a watch expression other than
the current one, select the desired watch expression by
highlighting it. Then choose Delete Watch. When the Watch
Window is active, you can press Del or Ctrl+ Y to delete a watch.
Edit Watch The Edit Watch command allows you to edit the current watch
expression in the Watch window. A history list is available to save
you time retyping. _
When you choose this command, the debugger opens a dialog
box containing a copy of the current watch expression. Edit the
expression and press Enter. The debugger replaces the original
version of the expression with the edited one.
You can also edit a watch expression from inside the Watch
window by selecting the expression and pressing Enter.
Chapter 3, Menus and options reference 75
Debug I Watches I Remove All Watches
Remove All Watches The Remove All Watches command deletes all watch expressions
from the Watch window.
Toggle Breakpoint
eVA
[ffi
Alternate
@liDffiJ
Breakpoints
Figure 3.6
The Breakpoints dialog box
76
The Debug I Toggle Breakpoint command lets you set or clear an
unconditional breakpoint on the line where the cursor is
positioned. When a breakpoint is set, it is marked by a breakpoint
highlight. Breakpoints can be saved across sessions using
Options I Environment I Desktop.
The Debug I Breakpoints command opens a dialog box that lets
you control the use of breakpoints-both conditional and
unconditional ones. Here is what the dialog box looks like:
The dialog box shows you all set breakpoints, their line numbers,
and the conditions. The condition has a history list so you can
select a breakpoint condition you've used before.
The row of buttons at the bottom of the dialog box give you
several options:
Choose Delete to remove a highlighted breakpoint from your
program.
Choose View to display the source code where the selected
breakpoint is set.
Choose At to set a breakpoint at a particular function. You must
be debugging to choose At.
Choose Edit to add a new breakpoint or modify an existing one.
The Breakpoint Modify /New dialog box appears:
Borland C++ User's Guide
Figure 3.7
The Breakpoint Modify/New
dialog box
Debug I Breakpoints
If you choose New, a breakpoint is set at the location of your
cursor in the active Edit window. You can modify a breakpoint by
making changes in this dialog box.
The Condition text box accepts any expression that evaluates to
either true or false. When your program reaches that condition
while you're debugging, it stops executing.
You can specify when the debugger should stop on the
breakpoint. In the Pass Count text box, type in a number. If you
enter a 1, the debugger stops the first time the breakpoint is
reached. If you enter a 2, the debugger stops the second time the
b,reakpoint is reached, and so on.
Generally you will not change the file name, but you can if you
want. You can also specify a new line number. The primary
purpose of these two options is to identify a breakpoint you have
already set.
When you are done modifying your breakpoint, choose Modify
and the IDE accepts the new settings.
When a source file is edited, each breakpoint "sticks" to the line
where it is set. Breakpoints stay set until you
.. delete the source line a breakpoint is set on
g clear a breakpoint with Toggle Breakpoint
Borland C++ continues to track breakpoints until
.. you edit a file containing breakpoints and then don't save the
edited version of the file .
.. you edit a file containing breakpomts and then continue. the
current debugging session without remaking the program.
(Borland C++ displays the warning prompt "Source modified;
rebuild ?")
Chapter 3, Menus and options reference 77
Debug I Breakpoints
Project menu
Before you compile a source file, you can set a breakpoint on any
line, even a blank line or a comment. When you compile and run
the file, Borland C++ validates any breakpoints that are set and
gives you a chance to remove, ignore, or change invalid
breakpoints. When you are debugging the file, Borland C++
knows which lines contain executable statements, and warns you
if you try to set invalid breakpoints.
You can set an unconditional breakpoint without going through
the dialog box by choosing the Debug I Toggle Breakpoint
command.
The Project menu contains all the project-management commands
to
_ create a project
_ add or delete files from your project
Borland C++ DOS IDE only _ specify which program your source file should be translated
78
with
_ set options for a file in the project
Borland C++ DOS IDE only _ specify which command-line override options to use for the
Open Project
translator program
_ specify what the resulting object module is to be called, where it
should be placed, whether the module is an overlay, and if the
module should contain debug information
_ view included files for a specific file in the project
The Open Project command displays the Open Project File dialog
box, where you select and load a project or create a new project by
typing in a name.
This dialog box lets you select a file name in a similar way to the
File I Open dialog box, discussed on page 47. The file you select
will be used as a project file, which is a file that contains all the
information needed to build your executable. Borland
C++ uses the project name when it creates the .EXE, .DLL, or .LIB
file and .MAP file. A typical project file has the extension .PRJ.
Borland C++ User's Guide
Close Project
Add Item
When the Project Window is
active, you can press Ins to
add a file. In Borland c++ for
Windows, you can also use
the SpeedBar.
Delete Item
Local Options
Figure 3.8
The Local Options dialog box
Project I Close Project
Choose Project I Close Project when you want to remove your
project and return to the default project.
Choose Project I Add Item when you want to add a file to the
project's file list. This brings up the Add to Project List dialog box.
This dialog box is set up much like the Open a File dialog box
(File I Open). Choosing the Add button puts the currently
highlighted file in the Files list into the Project window. The
chosen file is added to the Project window File list immediately
before the highlight bar in the Project window. The highlight bar
is advanced each time a file is added.
Choose Project I Delete Item when you want to delete the
highlighted file in the Project window. When the Project window
is active, you can press Del to delete a file.
The Local Options command opens the following dialog box in
the Borland C++ DOS IDE:
The Borland C++ for Windows IDE has the following Local
Options dialog box:
Chapter 3, Menus and options reference 79
Project I Local Options
Figure 3.9
The Borland C++ for Windows
Local Options dialog box
These command-line options
are not supported: c, E, e, I,
L,I,M,Q,y.
Borland C++ DOS IDE only
I [ ] Overl ay thi s modul e I
Borland C++ DOS IDE only
I [] Excl ude debug i nformat ion
I [] Exclude from link
80
The Local Options dialog box lets you include command-line
override options for a particular project-file module. It also lets
you give a specific path and name for the object file.
The DOS IDE also lets you choose a translator for the module.
Any program you installed in the Transfer dialog box with the
Translator option checked appears in the list of Project File
Translators (see page 102 for information on the Transfer dialog
box).
Check Overlay This Module if you want the selected project item
to be overlaid. This item is local to one file. It is ignored if the
Overlaid DOS EXE option is not selected in the Output radio
button in Options I Linker I Settings.
Check Exclude Debug Information to prevent debug information
included in the module you've selected from going into the .EXE.
Use this switch on modules of large programs that you've already
debugged. You can change which modules have debug
information by checking this box and then relinking (no
compiling is required). .
Check the Exclude from Link option if you don't want this
module linked in.
Borland C++ User's Guide
Include Files
Figure 3.10
The Include Files dialog box
Browse menu
Project I Include Files
Choose Project I Include Files to display the Include Files dialog
box or, if you're in the Project window, press the Spacebar. If you
haven't built your project yet, the Project I Include Files command
is disabled.
The Include Files dialog box in the DOS IDE looks like this:
\INCLUDE
You can scroll'through the list of files displayed. Select the file
you want to view and press Enter.
10 The Browse menu in the Borland C++ for Windows IDE gives you
lEl access to the ObjectBrowser so you can visually browse through
the class hierarchies, functions, and variables in your Windows
applications. Turbo Debugger offers browsing features for DOS
programs.
You must check Options I
Compiler I Advanced Code
Generation I Browser Into In
OBJs to use the Object-
Browser.
To browse with your mouse,
choose Options I
Environment I Mouse and
select the Browse Right
Mouse Button option.
Before you can use the ObjectBrowser, you must compile your
program so that browsing information is included in your
executable file. Open the related project file in the IDE before
using the ObjectBrowser.
You can access the ObjectBrowser either through the Browse
menu or directly fromyour source code by clicking the right
mouse button on the class, function, or variable you wish to
inspect.
The ObjectBrowser has buttons on the title bar of the Object-
Browser window. Choose them by clicking them with your
mouse or using specific key combinations. By choosing one of
Chapter 3, Menus and options reference 81
Browse
Classes
Functions
Press Tab or Ctrl+S to move
the focus to the search field.
82
these buttons, you tell the ObjectBrowser to perform some action.
Not all of the buttons are available at all times. These are the
buttons you will see, their keyboard equivalents, and the action
they perform:
F1 Help
Ctr/+G Go to the source code for the selected item
Ctr/+/ Inspect (view the details of) the selected item
Ctr/+R Rewind the ObjectBrowser to the previous view
Ctr/+O Show an overview of the class hierarchy
The Browse I Classes command opens an ObjectBrowser window
that displays all the classes in your application, arranged as a .
horizontal "tree" to show parent-child relationships. The window
is automatically sized to display as much of your class hierarchy
as possible. If the entire image does not fit within the window, use
the scroll bars to move the image to view hidden sections. You
can highlight any class in the display by using the arrow keys, or
by clicking directly on the class name. Using the buttons at the top
of the ObjectBrowser window, you can
exit the ObjectBrowser
go to the source code that defines the highlighted class
inspect the functions and data elements of the highlighted class
The Functions command opens a window that lists every function
in your program, in alphabetical order. Class-member functions
are listed together by class (for example, MyClass::MyFunc). In
addition, an incremental search field is provided at the bottom of
the dialog box that lets you quickly search through the function
Borland C++ User's Guide
Variables
Symbols
You can also inspect a
symbol by clicking it in your
source code with your right
mouse button. Set up your
mouse this way with
Options I Environment I
Mouse and select Browse.
Rewind
Overview
Browse I Functions
list by typing the first few letters of the function name. As you
type, the selections in the list change to match the characters you
have typed in. Using the buttons at the top of the ObjectBrowser
window, you can
II exit the ObjectBrowser
go to the source code that defines the highlighted function
CI inspect the declaration of the highlighted function
The Variables command opens a window that lists every global
variable in your program, in alphabetical order. This dialog box
also contains an incremental search field. Using the buttons at the
top of the ObjectBrowser window, you can
exit the ObjectBrowser
a open an edit window on the source code that defines the
highlighted variable
I! inspect the declaration of the highlighted variable
The Symbol at Cursor command opens an ObjectBrowser window
for the symbol the cursor is on in the active edit window. The
symbol may be any class, function, or variable symbol that is
defined in your source code.
The Rewind command takes the ObjectBrowser back to the
previous view. Choosing the Rewind command is the same as
choosing the Rewind button.
The Overview command shows an overview. An overview of
classes is the class hierarchy. An overview of is a list of
all functions. An overview of variables is a list of all variables.
Choosing the Overview command is the same as choosing the
Overview button.
Chapter 3, Menus and options reference 83
Browse I Inspect
Inspect
Goto
Options menu
84
The Set
Application
Options dialog
box
The Inspect command displays the detail of the selected item.
Choosing the Inspect command is the same as choosing the
Inspect button.
The Goto command takes you to the source code for the selected
item. Choosing the Goto command is the same as choosing the
Goto button.
The Options menu contains commands that let you view and
change various default settings in Borland C++. Most of the
commands in this menu lead to a dialog box.
When you first view the settings in any of the Options dialog
boxes, you will see certain settings are already selected. These are
the default settings, which Borland C++ uses if you don't make
any changes. These default settings are illustrated in the screen
diagrams in this chapter. You can change any of the default
settings by making the desired changes and selecting save project
on the Options I Save dialog box. Alternatively, if you check the
Project box in the Autosave group on the Options I Environment I
Preferences menu, your changes are automatically saved when
you exit from Borland C++.
The Options I Application menu choice brings up the Set
Application Options dialog box. This dialog box provides the
easiest and safest way to set up compilation and linking for a DOS
or Windows executable. To use this dialog box, simply click one
of the buttons. Borland C++ will verify and, if necessary, change
some of the settings in the Code Generation, Entry/Exit Code
Generation, and Linker dialog boxes. See page 91 (Entry/Exit
Code) for detailed information on the code generated. Use this
dialog box for initial setup only.
Bor/and c++ User's Guide
Figure 3.11
The Set Application Options
dialog box
Options I Application
In the Borland C++ for Windows environment, only the Windows
App and Windows DLL options are available. Standard DOS and
DOS overlay applications must be compiled with the Borland
C++ DOS IDE (or using the Borland C++ command-line
compiler).
IPIHI====r; Set Application Options =======
Current Settings
The standard options for applications and libraries each
accomplish a set of tasks. You can choose only one button at a
time. The current settings fields are updated when you set the
button.
Borland C++ DOS IDE only DOS Standard:
sets the Small memory-model radio button in the Code
Generation dialog box
sets Assume SS equals DS to Default for memory model in the
Code Generation dialog box
sets the DOS Standard radio button in the Entry/Exit Code
Generation dialog box
sets the Standard DOS .EXE radio button in the Linker I Settings
dialog box
Borland C++ DOS IDE only DOS Overlay:
sets the Medium memory-model button in the Code Generation
dialog box
sets Assume SS equals DS to Default for memory model in the
Code Generation dialog box
.. sets the DOS Overlay button in the Entry/Exit Code Generation
dialog box
sets the Overlaid DOS .EXE button in the Linker I Settings
dialog box
Chapter 3, Menus and options reference
85
Options I Application
Compiler
Windows App:
sets the Small memory-model button in the Code Generation
dialog box
sets Assume SS equals DS to Default for memory model in the
Code Generation dialog box
sets the Windows All Functions Exportable button in the
Entry /Exit Code Generation dialog box .
sets the Windows .EXE button in the Linker I Settings dialog
box
unchecks the Graphics Library option in the Libraries dialog
box
Windows DLL:
sets the Compact memory-model button in the Code
Generation dialog box
sets Assume SS equals DS to Never in the Code Generation
dialog box
sets the Windows DLL All Functions Exportable button in the
Entry /Exit Code Generation dialog box
sets the Windows .DLL button in the Linker I Settings dialog
box
unchecks the Graphics Library option in the Libraries dialog
box
The Options I Compiler command displays a pop-up menu that
gives you several options that affect code compilation. The
following sections describe these commands.
Code Generation The Code Generation command displays a dialog box with
settings that tell the compiler to prepare the object code in certain
ways. The dialog box looks like this:
86 Borland C++ User's Guide
Figure 3.12
The Code Generation dialog
box
Options
Model
( ) Ti ny
( ) Small
( ) Medium
( ) Compact
( ) Large
( ) Huge
[X] Treat enums as ints
[ ] Word alignment
[ ] Duplicate strings merged
[ ] Unsigned characters
[ ] Pre-compiled headers
[ ] Generate assembler source
[ ] Compile via assembler
Options I Compiler I Code Generation
Here are what the various buttons and check boxes mean:
The Model buttons determine which memory model you want to
use. The default memory model is Small. The memory model
chosen determines the normal method of memory addressing.
Refer to Chapter 9, "DOS memory management," in the
Programmer's Guide for more information about memory models in
generaL
There are some restrictions about which memory models you can
use for Windows executables. The Borland C++ for Windows IDE
allows you to select Small, Medium, Compact, and Large memory
models. Tiny and Huge are not supported.
The options control various code-generation defaults .
When checked, Treat Enums As Ints causes the compiler to
always allocate a whole word for variables of type enum.
Unchecked, this option tells the compiler to allocate an
u n s i g n ~ d or signed byte if the minimum and maximum values
of the enumeration are both within the range of 0 to 255 or -128
to 127, respectively .
Word Alignment (when checked) tells Borland C++ to align
noncharacter data (within structures and unions only) at even
addresses. When this option is off (unchecked), Borland C++
uses byte-aligning, where data (again, within structures and
unions only) can be aligned at either odd or even addresses,
depending on which is the next available address.
Word alignment increases the speed with which 80x86
processors fetch and store the data.
Chapter 3, Menus and options reference 87
Options I Compiler I Code Generation
See Appendix 0 for more on
precompiled headers.
Borland C++ DOS IDE only
Borland C++ DOS IDE only
Assume SS Equals DS
(e) Default for memory model
( ) Never
( ) Always
IDefines
88
Duplicate Strings Merged (when checked) tells Borland C++ to
merge two strings when one matches another. This produces
smaller programs, but can introduce bugs if you modify one
string.
Unsigned Characters (when checked) tells Borland C++ to treat
all char declarations as if they were unsigned char type.
Check Precompiled Headers when you want the I D ~ to
generate and use precompiled headers. Precompiled headers
can dramatically increase compilation speeds, though they
require a considerable amount of disk space. When this option
is off (the default), the IDE neither generates nor uses
precompiled headers. Precompiled headers are saved in
PRO]ECTNAME.SYM.
Check Generate Assembler Source to tell Borland C++ to
produce an .ASM assembly language source file as its output,
rather than an .OBI object module.
Compile Via Assembler allows you to specify that the compiler '
should produce assembly language output, then invoke T ASM
to assemble the output.
If the Default For Memory Model radio button is set, whether the
stack segment (SS) is assumed to be equal to the data segment
(DS) is dependent on the memory model used. Usually, the
compiler assumes that SS is equal to DS in the Small, Tiny, and
Medium memory models (except for DLLs).
When the Never radio button is set, the compiler does not assume
SS is equal to DS.
The Always button tells the compiler to always assume that SS is
equal to DS. It causes the IDE to substitute the COFx.OBI startup
module for COx.OBI to place the stack in the data segment.
Use the Defines input box to enter macro definitions to the
preprocessor. You can separate multiple defines with semicolons
(;) and assign values with an equal sign (=); for example,
TESTCODE;PROGCONST=5
Leading and trailing spaces are stripped, but embedded spaces
are left intact. If you want to include a semicolon in a macro, you
must place a backslash (\rin front of it.
Borland C++ User's Guide
Advanced Code
Generation
Figure 3.13
The Advanced Code
Generation dialog box
Options
Floating Point
( ) None
lI{e) [jnulation
( ) 8087
( ) 80287/387
Instruction Set
(e) 8088/8086
( ) 80186
. ( ) 80286
( ) 80386
[X] Generate underbars
[ ] Line numbers debug info
[X] Debug info in OBJs
[ ] Browser info in OBJs
[X] Fast floating point
[ ] Fast huge pointers
[ ] Generate COMDEFs
[ ] Automatic far data
Options I Compiler I Advanced Code Generation
The Advanced Code Generation menu option opens the
Advanced Code Generation dialog box. Here's what that dialog
box looks like:
The Floating Point buttons let you decide how you want Borland
C++ to generate floating-point code. .
Choose None if you're not using floating point. (If you choose
None and you use floating-point calculations in your program,
you get undefined symbols, such as FIWRQQ, at link time.)
II Choose Emulation if you want your program to detect if your
computer has an 80x87 coprocessor (and to use it if you do). If it
is not present, your program will emulate the 80x87.
Choose 8087 or 80287/387 to generate direct inline code for the
appropriate math coprocessor.
The Instruction Set radio buttons let you choose which instruction
set to generate code for. The default instruction set, 8088/8086,
works with all PCs. Since Windows protected mode requires an
80286 or higher, only those options are available in Borland C++
for Windows.
When checked, the Generate Underbars option automatically
adds an underbar, or underscore, character ( _ ) in front of every
global identifier (that is, functions and global variables). If you
are linking with standard libraries, this box must be checked.
Line Numbers Debug Info (when checked) includes line
numbers in the object and object map files (the latter for use by
a symbolic debugger). This increases the size of the object and
map files but does not affect the speed of the executable pro-
gram.
Since the compiler might group together common code from
multiple lines of source text during jump optimization, or
Chapter 3, Menus and options reference
89
Options I Compiler I Advanced Code Generation
Borland C++ DOS IDE only
See page 157 for more
details on fast huge pointers.
This option is ignored if you're
using the Tiny, Small, or
Medium memory models.
90
might reorder lines (which makes line-number tracking
difficult), you might want to make sure the Jump Optimization
check box (Options I Compiler I Optimizations) is off
(unchecked) when this option is checked.
Debug Info In OBJ s controls whether debugging information is
included in object (.OBJ) files. The default for this check box is
on (checked), which you need in order to use either the
integrated debugger or the standalone Turbo Debugger.
Turning this option off allows you to link and create larger
object files. While this option doesn't affect execution speed, it
does affect compilation time.
Browser Info In OBJs controls whether information needed by
the Borland C++ for Windows ObjectBrowser is included in
object (.OBJ) files. The default for this check box is off
(unchecked). If you want to use ObjectBrowser to inspect your
program (from within the Borland C++ for Windows IDE), you
must turn this option on.
Leaving this option off saves space in your object files.
II Fast Floating Point lets you optimize floating-point operations
without regard to explicit or implicit type conversions. When
this option is unchecked, the compiler follows strict ANSI rules
regarding floating-point conversions.
m The Fast Huge Pointers option normalizes huge pointers only
when a segment wrap-around occurs in the offset portion of the
segment. This greatly speeds up the computation of huge
pointer expressions, but must be used with caution, as it can
cause problems for huge arrays if array elements cross a
segment boundary.
When checked, the Generate COMDEFs option allows a
communal definition of a variable to appear in header files as
long as it is not initialized. Thus a definition such as int
SomeArray [256] i could appear in a header file that is then
included in many modules. The compiler will generate it as a
communal variable rather than a public definition (a COMDEF
record rather than a PUBDEF record). The linker will then only
generate one instance of the variable so no duplicate-definition
linker error will occur.
The Automatic Far Data option and the Far Data Threshold
type-in box work together. When checked, the Automatic far
data option tells the compiler to automatically place data
objects larger than a predefined size into far data segments; the
Borland C++ User's Guide
Entry/Exit Code
See Chapter 8 in the
Programmer's Guide for
more on prolog and epilog
code.
Figure 3.14
The Entry/Exit Code
Generation dialog box
Options I Compiler I Entry/Exit Code
far data threshold specifies the minimum size above which data
objects will be automatically made far.
When you compile a C or C++ program for Windows or DOS, the
compiler needs to know which kind of prolog and epilog to create
for each of a module's functions.
If the program is intended for Windows, the compiler generates a
different prolog and epilog than it would for DOS. Because of
this, you must use the Entry /Exit Code Generation dialog box to
set the appropriate application. If you use the Set Application
Options dialog box (described on page 84), the settings in the
Entry /Exit Code dialog box already are correct for the type of
application you choose.
This dialog box also allows you to select the calling convention
and to set a couple of stack options. All options affect what code is
generated for function calls and returns.
If you want to set the prolog/ epilog code for a DOS application,
select DOS Standard or DOS Overlay.
Borland C++ DOS IDE only m Set the DOS Standard radio button to tell the compiler to
generate code that may not be safe for overlays. If you don't
plan to create an overlaid application, use this option.
Borland C++ DOS IDE only c Set the DOS Overlay radio button to tell the compiler to
generate overlay-safe code. Use this option when you're
creating an overlaid application.
To set the prolog/ epilog code for a Windows application, you
need to select one of five options.
II Windows All Functions Exportable is the most general kind of
Windows executable, although not necessarily the most
efficient. It assumes that all functions can be called by the
Chapter 3, Menus and options reference
91
Options I Compiler I Entry/Exit Code
92
Calling Convention
(e) C
( ) Pascal
( ) Regi ster
Borland C++ DOS IDE only
Stack Options
[X] Standard stack frame
[ ] Test stack overflow
Windows kernel or by other modules, and generates the
necessary overhead information for every function, whether the
function needs it or not. The module-definition file controls
which functions are exported.
Use Windows Explicit Functions Exported if you have
functions that will not be called by the Windows kernel; it isn't
necessary to generate export-compatible prolog/ epilog code
information for these functions. The _export keyword provides
a way to tell the which specific functions will be
exported: Only those far functions with _export will be given
the special Windows prolog/ epilog code.
Set Windows Smart Callbacks to select Borland C++ smart
callbacks. See Chapter 8, "Building a Windows application," in
the Programmer's Guide for details on smart callbacks.
Set Windows DLL All Functions Exportable to create an .OBI
file to be linked as a .DLL with all functions exportable.
Set Windows DLL Explicit Functions Exported to create an .OBI
file to be linked as a .DLL with certain functions explicitly
selected to be exported. Otherwise, this is essentially the same
as Windows Explicit Functions Exported; see that discussion for
more information.
The Calling Convention options cause the compiler to generate
either a C or Pascal calling sequence for function calls. The
differences between C and Pascal calling conventions are the way
each handles stack cleanup, order of parameters, case, and prefix
(underbar) of global identifiers.
In the Borland C++ IDE, you can also select Register to specify the
new fastcall parameter-passing convention. For more information
about the fastcall convention, see Appendix A, "The Optimizer."
Do not change this option unless you're an expert and have read
Chapter 12, "BASM and inline assembly," in the Programmer's Guide.
Standard Stack Frame (when checked) generates a standard
stack frame (standard function entry and exit code). This is
helpful when debugging-it simplifies the process of tracing
back through the stack of called subroutines.
If you compile a source file with this option off (unchecked),
any function that does not use local variables and has no
parameters is compiled with abbreviated entry and return code.
This makes the code shorter and faster, but prevents the
Debug I Call Stack command from "seeing" the function. Thus,
Bor/and c++ User's Guide
Options I Compiler I Entry/Exit Code
you should always check the option when you compile a source
file for debugging.
This option is automatically turned off when you tum
optimizations on; a duplicate of the Standard Stack Frame
option also appears on the Options I Compiler I Optimization
dialog box.
When checked, the Test Stack Overflow generates code to check
for a stack overflow at run time. Even though this costs space
and time in a program, it can be a real lifesaver, since a stack
overflow bug can be difficult to track down.
c++ Options The C++ Options command displays a dialog box with settings
that tell the compiler to prepare the object code in certain ways
when using C++.
Figure 3.15
The C++ Options dialog box
Use C++ Compiler
Ce) CPP eltension
( ) C++ always
C++ Virtual Tables
(e) Smart
( ) Local
( ) External
( ) Public
The Use C++ Compiler radio buttons tell Borland C++ either to
always compile your programs as C++ code, or as C code except
when the file extension is .CPP.
The C++ Virtual Tables radio buttons let you control C++ virtual
tables and the expansion of inline functions when debugging.
The Smart option generates C++ virtual tables (and inline
functions not expanded inline) so that only one instance of a
given virtual table or inline function are included in the
program. This produces the smallest and most efficient
executables, but uses .OBI (and .ASM) extensions only available
with TLINK 3.0 and TASM 2.0 (or newer).
The Local option generates local virtual tables (and inline
functions not expanded inline) such that each module gets its
own private copy of each virtual table or inline function it uses;
this option uses only standard .OBI (and .ASM) constructs, but
produces larger executables.
Chapter 3, Menus and options reference
93
Options I Compiler I C++ Options
94
Template Generation
(e) Smart
( ) Global
( ) External
The External option generates external references to virtual
tables; one or more of the modules comprising the program
must be' compiled with the Public option to supply the
definitions for the virtual tables.
The Public option generates public definitions for virtual tables.
The Template Generation options allow you to specify how
Borland C++ generates template instances in C++. For more
information about templates, see Chapter 3 "C++ specifics," in the
Programmer's Guide.
Smart generates public (global) definitions for all template
instances, but if more than one module generates the same
template instance, the linker automatically merges duplicates to
produce a single definition. This is the default setting, and is
normally the most convenient way of generating template
instances.
Global, like Smart, generates public definitions for all template
instances. However, it does not merge duplicates, so if the same
template instance is generated more than once, the linker
reports public-symbol redefinition errors.
External tells the compiler to generate external references to all
template instances. If you use this option, you must make
certain the instances are publicly defined elsewhere in your
code.
Use Out-of-line Inline Functions when you want to step
through or set breakpoints on inline
Options
[X] Out-of-l i ne i nl i ne functi ons
[ ] Far virtual tables
The Far Virtual Tables option causes virtual tables to be created
in the code segment instead of the data segment, and makes
virtual table pointers into full 32-bit pointers (the latter is done
automatically if you are using the Huge memory model).
There are two primary reasons for using this option: to remove
the virtual tables from the data segment, which may be getting
full, and to share objects (of classes with virtual functions)
between modules that use different data segments (for example,
a DLL and an executable using that DLL). You must compile all
modules that can share objects either entirely with or entirely
without this option. You can achieve the same effect by using
, the huge or _export modifiers on a class-by-class basis.
Borland C++ User's Guide
Advanced C++
Options
Figure 3.16
The Advanced C++ Options
dialog box
options I Compiler I Advanced C++ Options
The Advanced c++ Options command displays a dialog box with
settings that control advanced code-generation options for C++.
Since Borland C++ handles certain C++ features more efficiently
(but differently) than previous versions of Borland C++, some of
these options are intended primarily for backward compatibility,
where it is necessary to link with object modules or libraries
compiled with older versions.
Borland C++ supports three different kinds of member-pointer
types, which you can control with these options.
C++ Member Poi nters
" (.) Support tilll cases
( ) Support multiple inheritance
( ) Support si n91 e i nheri tance
( ) Smallest for class
II Support All Cases (the default) places no restrictions on which
members can be pointed to. Member pointers will use the most
general (but not always the most efficient) representation.
II Support Multiple Inheritance allows member pointers to point
to members of multiple inheritance classes, with the exception
of members of virtual base classes.
E:I Support Single Inheritance permits member pointers to point to
members of base classes that use single inheritance only .
.. Smallest For Class specifies that member pointers use the
smallest possible representation that allows them to point to all
members of their particular class.
Chapter 3, Menus and options reference
95
Options I Compiler I Advanced C++ Options
96
Vi rtua 1 Base Poi nters
Ce) Always near
C) Same size as 'this' pointer
When a class inherits virtually from a base class, the compiler
stores a hidden pointer in the class object to access the virtual base
class subobject. Borland C++ always makes this hidden pointer a
near pointer by default, to generate more efficient code. Previous
versions of Borland C++ matched the size of this pointer to the
size of the this pointer used by the class itself.
Always Near specifies that the hidden pointer should always be
near, for the smallest and most efficient code.
Same Size As 'this' Pointer tells the compiler to match the size
of the hidden pointer to the size of the this pointer in the
instance class, for backward compatibility.
Options
[] 'Deep' vi rtua 1 bases
[ ] True ' Pascal' member functions
[ ] Honor precision of member pointers
[ ] Di sabl e constructor di spl acements
[] Pass class values via reference
[ ] Vtab 1 e poi nter follows data members
Borland C++ sometimes handles pointers differently from
previous versions, in order to permit greater efficiency and
flexibility. In some cases, this results in behavior that is
incompatible with previous versions. To permit complete
compatibility, the following options are provided:
'Deep' Virtual Bases directs the compiler not to change the
layout of any classes in order to relax the restrictions on
pointers to members of base classes through multiple levels of
virtual inheritance.
True 'Pascal' Member Functions directs the compiler to pass the
this pointer to pascal member functions as the first parameter
on the stack. By default, Borland C++ passes the this pointer as
the last parameter, which permits smaller and faster member
function calls.
Honor Precision Of Member Pointers tells the compiler to
honor an explicit cast to a pointer to a member of a simpler base
class, even though it is actually pointing to a derived class
member.
Disable Constructor Displacements instructs the compiler not to
add hidden members and code to a derived class, which it does
by default to prevent an erroneous value for the this pointer in
special cases where the constructor of a derived class containing
Borland C++ User's Guide
Optimizations
Figure 3.17
The Optimization Options
dialog box
Options I Compiler I Advanced C++ Options
an inherited virtual function that it overrides, calls that function
using a pointer to the virtual base class. This option ensures
compatibility with the behavior of previous versions .
.. Pass Class Values Via Reference tells the compiler to use a
reference to a temporary variable in order to pass arguments of
type class to a function. By default Borland C++ copy-
constructs the argument values directly to the stack.
II Vtable Pointer Follows Data Members instructs the compiler to
place virtual table pointers after any nonstatic data members of
the class, for compatibility with previous versions of Borland
C++. The default is to place these pointers before any nonstatic
data members, to make virtual member function calls smaller
and faster.
The Optimizations Options dialog box presents you with three
separate categories of options, to let you fully customize the way
the compiler optimizes your code. These features are listed briefly
below. For your convenience, the command-line compiler
switches corresponding to each option are indicated. A more
complete discussion of optimization, including a description of
the use and functionality of each menu option, appears in
Appendix A, "The Optimizer."
zations
[]lobal register allocation
Invari ant code moti on
Induction variables
Loop optimization
Supress 'redundant loads
Copy propagati on
Assume no pointer al iasing
Dead code elimination
Jump optimization
Inline intrinsic functions
Standard stack frame
ect data call i
--
Chapter 3, Menus and options reference 97
Options I Compiler I Optimizations
.. . The Optimizations Options affect how optimization of your code
Optlmlzatlons
[ ] Global register allocation occurs.
[ ] Invariant code motion
[ ] Induction variables
[ ] Loop optimizations
[ ] Suppress redundant loads
[ ] Copy propagation
[ ] Assume no pOinter aliasing
[ ] Dead code elimination
[ ] Jump optimization
[ ] Inline intrinsic functions
[X] Standard stack frame
[ ] Object data calling
98
Register Variables
( ) None
( ) Register keyword
(.) Automati c
Global Register Allocation corresponds to the -Oe switch on the
command line compiler. It enables global register. allocation and
variable live range analysis.
Invariant Code Motion, corresponding to the -Om command
line switch, moves invariant code out of loops.
Induction Variables corresponds to the -Ov command line
switch. It enables loop induction variables and strength-
reduction optimizations.
Loop Optimizations corresponds to -01 option, and compacts
loops into REP /STOSx instructions.
II Suppress Redundant Loads corresponds to the -Z command
line switch. It suppresses reloads of values that are already in
registers.
Copy Propagation, corresponding to the -Op command line
switch, propagates copies of constants, variables, and
expressions where possible.
Assume No Pointer Aliasing corresponds to the -Oa command
line switch. It instructs the compiler to assume that pointer
expressions are not aliased in common subexpression
evaluation.
Dead Code Elimination corresponds to the -Ob command line
switch, and eliminates stores into dead variables.
Jump Optimization, corresponding to the -0 compiler switch,
removes jumps to jumps, umeachable 'code, and unnecessary
jumps.
Inline Intrinsic Functions, corresponding to the -Oi compiler
switch, instructs the compiler to expand common functions like
strcpy inline.
Standard Stack Frame instructs the compiler to generate a
standard function entry / exit code, and corresponds to the -k-
compiler option.
II Object Data Calling instructs the compiler to use the Object
Data calling convention, and corresponds to the -po compiler
option. See Appendix A for more information on Object Data.
The Register Variables selections affect how the compiler handles
the use of register variables. For more information about register
variables see Chapter 9, "DOS memory management," in the
Programmer's Guide.
Borland C++ User's Guide
Common subexpressions
(e) No optimization
( ) Optimize globally
( ) Optimize locally
Optimize For
(e) Size
( ) Speed
8
IFastest cOdel
I Small est Code I
Options I Compiler I Optimizations
None instructs the compiler not to use register variables even if
you have used the register keyword.
II Register Keyword specifies that register variables are used only
if you use the register keyword and a register is available.
l1li Automatic directs the compiler to automatically assign register
variables for you.
Common Sub expressions tells the compiler how to find and
eliminate duplicate expressions in your code, to avoid
reevaluating the same expression.
No Optimization instructs the compiler not to eliminate
common sub expressions.
DI Optimize Globally corresponds to the -Og command line
switch, and instructs the compiler to eliminate common
sub expressions within an entire function.
13 Optimize Locally corresponds to the -Oc command-line switch,
and instructs the compiler to eliminate common sub expressions
within basic blocks only.
The Optimize For options let you change Borland C++'s code-
generation strategy. For backward compatibility, these buttons
correspond to the same buttons in the Borland C++ for Windows
environment and in earlier versions of Borland C++. They are not
identical to the "Smallest Code" and "Fastest Code" buttons that
appear at the bottom of the Optimization dialog box.
The three buttons at the bottom of the Optimizations dialog box
allow you to specify" groups" of settings by making a single
selection.
II No Optimizing corresponds to the -Od command-line switch. It
automatically disables all of the optimization options.
II Fastest Code corresponds to the -02 command-line switch. It
automatically sets all of the optimization options to generate
the fastest possible code.
e! Smallest Code corresponds to the -01 command-line switch. It
automatically sets the optimization options to produce the
smallest possible code.
Chapter 3, Menus and options reference 99
Options I Compiler I Source
Source
Source Options
[ ] Nested comments
Keywords
(.) Borl and C++
( ) ANSI
( ) UNIX V
( ) Kernighan and Ritchie
Note that some of the
standard Borland C++
header files use Borland C++
extension keywords and are
therefore incompatible with
these options.
IIdentifier Length 321
Messages
100
The Source command displays a dialog box. The settings in this
box tell the compiler to expect certain types of source code. The
dialog box presents the following options:
The Nested Comments check box allows you to nest comments in
Borland C++ source files. Nested comments are not allowed in
standard C implementations. They are not portable.
The Keywords radio buttons tell the compiler how to recognize
keywords in your programs.
Choosing Borland C++ tells the compiler to recognize the
Borland C++ extension keywords, including near, far, huge,
asm, cdecl, pascal, interrupt, _es, _export, _ds, _cs, _ss, and
the register pseudovariables LAX, _BX, and so on). For a
complete list, refer to Chapter I, "Lexical elements," in the
Programmer's Guide.
Choosing ANSI tells the compiler to recognize only ANSI
keywords and treat any Borland C++ extension keywords as
normal identifiers.
Choosing UNIX V tells the compiler to recognize only UNIX V
keywords and treat any Borland C++ extension keywords as
normal identifiers.
Choosing Kernighan and Ritchie tells the compiler to recognize
only the K&R extension keywords and treat any Borland C++
extension keywords as normal identifiers.
Use the Identifier Length input box to specify the number (n) of
significant characters in an identifier. Except in C++, which
recognizes identifiers of unlimited length, all identifiers are
treated as distinct only if their first n characters are distinct. This
includes variables, preprocessor macro names, and structure
member names. The number can be from 1 to 32; the default is 32.
The Messages command displays a submenu that lets you set
several options that affect compiler error messages in the IDE.
Borland C++ User's Guide
'DisPlay1
'portability '
'ANSI Violations '
Ic++ warnings1
'FreqUent errors '
Options I Compiler I Messages
Display presents a dialog box that allows you to specify how (and
if) you want error messages to be displayed.
Errors: Stop After causes compilation to stop after the specified
number of errors have been detected. The default is 25, but you
can enter any number from 0 to 255.
Warnings: Stop After causes compilation to stop after the
specified number of warnings have been detected. The default
is 100, but you can enter any number from 0 to 255. (Entering 0
causes compilation to continue until the end of the file or until
the error limit you entered has been reached, whichever comes
first.)
The Display Warnings options allow you to choose whether the
compiler will display all warnings, only the warnings selected
in the Messages submenu option, or no warnings.
When you choose Portability on the Messages submenu, a dialog
box appears that lets you specify which types of portability
problems you want to be warned about.
Check the warnings you want to be notified of and uncheck the
ones you don't. Choose OK to return to the Compiler Messages
dialog box.
When you choose ANSI Violations on the Messages submenu, a
dialog box appears that lets you specify which, if any, ANSI
violations you want to be warned about.
Check the warnings you want to be notified of and uncheck the
ones you don't. Choose OK to return to the Compiler Messages
dialog box.
When you choose the C++ Warnings button in the Messages
submenu, another dialog box appears that lets you determine
which specific C++ warnings you want to enable.
Check the warnings you want to be notified of and uncheck the
ones you don't. Choose OK to return to the Compiler Messages
dialog box.
When you choose Frequent Errors in the Compiler Messages
dialog box, another dialog box appears that lets you specify which
frequently occurring errors you want to be warned about.
Check the errors you want to be notified of and uncheck the ones
you don't. Choose OK to return to the Compiler Messages dialog
box.
Chapter 3, Menus and options reference
101
Options I Compiler I Messages I Less frequent errors
102
ILess frequent errors 1
Choosing Less frequent errors lets you choose to be warned about
several less frequently occurring errors.
Check or uncheck these errors and choose OK to return to the
Messages dialog box.
Names The Names command brings up a dialog box that lets you change
the default segment, group, and class names for-code, data, and
BSS sections. Do not change the settings in this command unless you
are an expert and have read Chapter 9, "DOS memory management," in
the Programmer's Guide.
Transfer
Borland C++ DOS IDE only The Options I Transfer command (available in the Borland C++
DOS IDE only) lets you add or delete programs in the:: menu.
Once you've done so, you can run those programs without
actually leaving Borland C++. You return to Borland C++ after
you exit the program you transferred to. The Transfer command
displays this dialog box:
Figure 3.18
The Transfer dialog box
The Transfer dialog box has two sections:
the Program Titles list
the Transfer buttons
The Program Titles section lists short descriptions of programs
that have been installed and are ready to execute. You might need
to scroll the list box to see all the programs available.
The Transfer buttons let you edit and delete the names of
programs you can transfer to, as well as cancel any changes
you've made to the transfer list. There's also a Help button to get
more information about using the Transfer dialog box.
Borland C++ User's Guide
Figure 3.19
The Modify/New Transfer
Item dialog box
For a full description of these
powerful macros, see the
"Transfer macros" section in
UTlL.DOC
This step is optional.
Options I Transfer
Choose Edit to add or change the Program Titles list that appears
in the:: menu. The Edit button displays the Modify/New Trans-
fer Item dialog box.
If you're positioned on a transfer item when you select Edit, the
input boxes in the Modify/New dialog box are automatically
filled in; otherwise they're blank.
Unassigned
Shi ft F2
Shi ft F3
Shi ft F4
Shi ft F5
Shi ft F6
Shi ft F7
Shift F8
Shift F9
Shift FlO
Using the Modify /New Transfer Item dialog box, you take these
steps to add a new file to the Transfer dialog box:
1. Type a short description of the program you're adding on the
Program Title input box.
If you want your program to have a keyboard shortcut (like
the 5 in the Save command or the t in the Cut command), you
should include a tilde (-) in the name. Whatever character
follows the tilde appears in bold or in a special color in the ::
menu, indicating that you can press that key to choose the
program from the menu.
2. Tab to Program Path and enter the program name and
optionally include the full path to the program. (If you don't
enter an explicit path, only programs in the current directory
or programs in your regular DOS path will be found.)
3. Tab to Command Line and type any parameters or macro
commands you want passed to the program. Macro com-
mands always start with a dollar sign ($) and are entered in
uppercase. For example, if you enter $CAP EDIT, all output from
the program will be redirected to a special Edit window in
Borland C++.
4. If you want to assign a hot key, tab to the Hot Key options and
assign a shortcut to this program. Transfer shortcuts must be
Shift plus a function key (Alt+Shiftin the CUA command set).
Chapter 3, Menus and options reference 103
Options I Transfer
104
I[] Translator I
I Delete I
Transfer macros
Make
Figure 3.20
The Make dialog box
Keystrokes already assigned appear in the list but are
unavailable.
5. Now click or choose the New button to add this program to
the list.
To modify an existing transfer program, cursor to it in the
Program Titles list of the Transfer dialog box and then choose
Edit. After making the changes in the Modify/New Transfer Item
dialog box, choose the Modify button.
The Translator check box lets you put the Transfer program into
the Project File Translators list (the list you see when you choose
Project I Local Options). Check this option when you add a
transfer program that is used to build part of your project.
The Delete button removes the currently selected program from
the list and the :: menu.
The IDE recognizes certain strings of characters called transfer
macros in the parameter string of the Modify /New Transfer Item
dialog box. The transfer macros are fully documented in the
online file UTIL.DOC.
The Options I Make command displays a dialog box that lets you
set conditions for project management. Here's what the dialog box
looks like:
Note that the Borland C++ for Windows version of the Make
dialog box is slightly different from the Borland C++ version. In
Borland C++ User's Guide
Break Make On
C ) Warnings
Co) Errors
C ) Fatal errors
C ) All sources processed
After Compiling
C ) Stop
Co) Run linker
C ) Run librarian
Borland C++ DOS IDE only
Generate Import Li brary
() No
(.) Use DLL fi 1 e exports
() Use DEF fi 1 e exports
I [X] Check Auto-dependenci es I
Borland C++ for Windows
also creates auto-
dependency information for
.RC resource scripts it
compiles with the integrated
resource compiler.
The IDEs also store the auto-
dependency information in
the project file to increase
performance.
See the $DEP transfer macro
in UTlL.DOC.
Options I Make
Borland C++ for Windows, neither the Run Librarian nor the
Generate Import Library options are available.
Set the Break Make On radio buttons to set the condition that will
stop the making of a project. The default is to stop after compiling
a file with errors.
Set the After Compiling radio buttons to specify what to do after
all the source code modules defined in your project have been
compiled. You can choose Stop (leave .OBI files), Run linker to
generate an .EXE file, or Run librarian to combine your projects
.OBI files into a .LIB (library) file. The default is to run the linker
to generate an executable application.
These buttons control when and how IMPLIB is executed during
the MAKE process. The Use DLL File Exports option generates 'an
import library that consists of the exports in the DLL. The Use
DEF File Exports generates an import library of exports in the
DEF file. If either of these options is checked, MAKE invokes
IMPLIB after the linker has created the DLL. This option controls
how the transfer macro $IMPLIB is expanded.
When the Check Auto-dependencies option is checked, the Project
Manager automatically checks dependencies for every .OBI file on
disk that has a corresponding .CPP, .C, or .ASM source file in the
project list.
The Project Manager opens the .OBI file and looks for information
about files included in the source code. This information is always
placed in the .OBI file by both Borland C++ and Borland C++ for
Windows, as well as the command-line version of Borland C++
when the source module is compiled. Then every file that was
used to build the .OBI file is checked for time and date against the
time and date information in the .OBI file. The source file is
recompiled if the dates are different. This is called an autodepen-
dency check. If this option is off (unchecked), no such file checking
is done.
After the C++ or C source file is successfully compiled, the project
file contains valid dependency information for that file. Once that
information is in the project file, the Project Manager uses it to do
its auto dependency check. This is much faster than reading each
.OBI file.
Chapter 3, Menus and options reference
105
Options I Linker
\ 106
Linker
Settings
Figure 3.21
The Linker dialog box
Map Fil e
(e) Off
( ) Segments
( ) Publ i cs
( ) Detailed
Output
(e) Standard DOS EXE
( ) Overlaid DOS EXE
( ) Wi ndows EXE
( ) Wi ndows DLL
I[ ] Initialize segments I
I [X] Default librariesl
The Options I Linker command lets you make several settings that
affect linking. The Linker command opens a submenu containing
the choices Settings and Libraries.
Note that the Borland C++ and Borland C++ for Windows
environments provide slightly different linker options. This is
because Borland C++ for Windows is a "Windows only"
programming environment; therefore, DOS-oriented options
aren't supported.
In Borland C++ the Settings command opens this dialog box:
This dialog box has several check boxes and radio buttons. The
following sections contain short descriptions of what each does.
Set the Map File radio buttons to choose the type of map file to be
produced. For settings other than Off, the map file is placed in the
output directory defined in the Options I Directories dialog box.
The default setting for the map file is Off.
Set these radio buttons to select your application type. Standard
DOS EXE produces a normal executable that runs under DOS.
Overlaid DOS EXE produces an executable capable of being
overlaid. Windows EXE produces a Windows application, while
Windows DLL produces a Windows dynamic link library.
If checked, Initialize Segments tells the linker to initialize
uninitialized segments. (This is normally not needed, and makes
your .EXE files larger.)
Some compilers place lists of default libraries in the .OB} files they
produce. If Default Libraries is checked, the linker tries to find
Borland C++ User's Guide
![ ] Pack code segments!
![] Warn duplicate SymbOls!
! [X] "No stack" warni ng
Borland C++ DOS IDE only
![x] Case-sensitive Link!
I[] Case-sensitive exports I
I[] Compress debug infol
Code Pack Size 8192
Segment Alignment 512
Options I Linker I SeHings
any undefined routines in these libraries as well as in the default
libraries supplied by Borland C++. When you're linking with
modules created by a compiler other than Borland C++, you may
wish to leave this option off (unchecked).
This option applies only to Windows applications and DLLs.
When it's checked, the linker minimizes the number of code
segments by packing multiple code segments together; typically,
this improves performance. This option never creates segments
greater than 64K.
The Warn Duplicate Symbols option affects whether the linker
warns you about previously encountered symbols in .LIB files.
The "No stack" Warning option affects whether the linker
generates the "No stack" message. It's normal for a program
generated under the Tiny model to display this message if the
message is not turned off.
The "No Stack" Warning option does not appear in the Borland
C++ for Windows IDE, since Windows does not support the Tiny
model.
The Case-sensitive Link option affects whether the linker is case-
sensitive. Normally, this option should be checked, since C and
C++ are both case-sensitive languages.
By default, the linker ignores case with the names in the
IMPORTS and EXPORTS sections of the module-definition file. If
you want the linker to be case-sensitive in regard to these names,
check this option. This option is useful when you export
noncallback functions from DLLs-as in exported C++ member
functions. It's not necessary for normal Windows callback
functions (declared FAR PASCAL).
The Compress Debug Info option instructs the linker to compress
the debugging information in the output file. This option slows
down the linker, and should only be checked in the event of a
"Debugger information overflow" error when linking.
You can change the default code-packing size to anything
between 1 and 65,536 with Code Pack Size. See Chapter 4 in the
Tools and Utilities Guide for a more in-depth discussion of
desirable sizes.
With Segment Alignment, you can set the segment alignment. The
alignment factor will be automatically rounded up to the nearest
Chapter 3, Menus and options reference 107
Options I Linker I Libraries
108
power of 2 (meaning if you enter 650, it is rounded up to 1,024).
The numbers you enter must fall in the range of 2 to 65,535.
Libraries The Libraries dialog box has several radio buttons that let you
choose which libraries are automatically linked into your
application.
Figure 3.22
The Libraries dialog box
I[ ] Graphics libraryl
Borland C++ DOS IDE only
I [ ] Turbo Vision
Borland C++ DOS IDE only
Container class library
(e) None
( ) Static
( ) Dynami c
The Graphics Library option controls the automatic searching of
the BGI graphics library. When this option is checked, you can
build and run single-file graphics programs without using a
project file. Unchecking this option speeds up the link step
because the linker doesn't have to search in the BGI graphics
library file.
The BGI Graphics library is not Windows-compatible, so this
option does not appear in the Borland C++ for Windows IDE ..
You can uncheck this option and still build programs that use BGI
graphics, provide9. you add the name of the BGI graphics library
(GRAPHICS. LIB) to your project list.
The Turbo Vision library option instructs the linker to
automatically include the Turbo Vision application framework
library when linking your application.
Turbo Vision is a DOS character-mode application framework. It
is not Windows-compatible, and this option does not appear in
the Borland C++ for Windows IDE.
The Container class library option tells the linker to automatically
link in the Borland C++ container class library, which is available
in both static (.LIB) and dynamic (.DLL) form. These radio buttons
tell the linker which, if either, form of the Container class library
you want to automatically link in with your application.
Borland C++ User's Guide
ObjectWindows Library
(e) None
( ) Static
( ) Dynami c
The easiest way to define this
macro is to include it in the
Options I Compiler I Code
Generation I Defines input
box.
Standard Run-time Libraries
( ) None
(e) Static
( ) Dynami c
The easiest way to define this
macro is to include it in the
Options I Compiler I Code
Generation I Defines input
box.
Table 3.4
DLL interdependencies
Options I Linker I Libraries
ObjectWindows is a Windows application framework available in
both static (.LIB) and dynamic (.DLL) form. These radio buttons
tell the linker which, if either, form of the ObjectWindows library
you want to automatically link in with your application.
To use the DLL version of the container class library or Object-
Windows, you must:
II choose Options I Compiler I Code Generation I Large
iii choose Options I Linker I Settings I Case-sensitive Link
choose Options I Linker I Settings I Case-sensitive Exports
II choose Options I Compiler I Entry/Exit Code I Windows Smart
Callbacks
.. define the macro __ CLASSDLL
The standard run-time libraries are available in both static (.LIB)
and dynamic (.DLL) form. Choosing the dynamic form can help
to reduce the size of your Windows executable file, and can also
reduce the overhead of loading these libraries more than once if
they will be called by more than one application running
simultaneously.
To use the DLL version of the run-time library, you must choose
Dynamic and: .
E:'I choose Options I Compiler I Code Generation I. Large
II choose Options I Linker I Settings I Case-sensitive Link
.. choose Options I Linker I Settings I Case-sensitive Exports
.. define the macro __ RTLDLL
When you use DLL versions of the libraries, you might also have
to use the DLL versions of other libraries. See the following table
for more information.
Library
Run-time library
Container class library
ObjectWindows
Other libraries required
None
Run-time library
Run-time library, container class library
Chapter 3, Menus and options reference 109
Options I Librarian .
Librarian
Figure 3.23
The Librarian Options dialog
box
ILibrar
y
Page sizel
Debugger
The Options I Librarian command lets you make several settings
affecting the use of the built-in Librarian. Like the command-line
librarian (TLIB), the built-in Librarian combines the .OBJ files in
your project into a .LIB file.
The Generate List File check box determines whether the
Librarian automatically produces a list file (.LST) listing the
contents of your library when it is created.
The Case Sensitive Library check box tells the Librarian to treat
case as significant in all symbols in the library (this means that
CASE, Case, and case, for example, would be treated as
different symbbls).
The Purge Comment Records check box tells the Librariart to
remove all comment records from modules added to the
library.
The Create Extended Dictionary check box determines whether
the Librarian will include, in compact form, additional
information that will help the linker to process library files
faster.
The Library Page Size option allows you to set the number of
bytes in each library "page" (dictionary entry). The page size
determines the maximum size of the library: it cannot exceed
65,536 pages. The default page size, 16, allows a library of about
1MB in size. To create a larger library, change the page size to the
next higher value (32).
Borland C++ DOS IDE only The Options I Debugger command lets you make several settings
affecting the integrated debugger. (Borland C++ for Windows
does not contain an integrated debugger, so this option does not
110 Borland C++ User's Guide
Figure 3.24
The Debugger dialog box
Source Debugging
(.) On
( ) Standalone
( ) None
Display Swapping
( ) None
(.) Smart
( ) Always
Options I Debugger
appear in the Borland C++ for Windows IDE.) This command
opens this dialog box:
The-following sections describe the contents of this box.
The Source Debugging radio buttons determine whether
debugging information is included in the executable file and how
the .EXE is run under Borland C++.
Programs linked with this option set to On (the default) can be
debugged with either the integrated debugger or the standalone
Turbo Debugger. Set this On when you want to debug in the IDE.
If you set this option to Standalone, programs can be debugged
only with Turbo Debugger, although they can still be run in
Borland C++.
If you set this option to None, programs cannot be debugged with
either debugger, because no debugging information has been
placed in the .EXE file.
The Display Swapping radio buttons let you set when the
integrated debugger will change display windows while running
a program.
If you set Display Swapping to None, the debugger does not swap
the screen at all. You should only use this setting for debugging
sections of code that you're certain do not output to the screen.
When you run your program in debug mode with the default
setting of Smart, the debugger looks at the code being executed. to
see whether it will generate output to the screen. If it does (or if it
calls a function), the screen is swapped from the IDE screen to the
User Screen long enough for output to be displayed, then is
swapped back. Otherwise, no swapping occurs.
Chapter 3, Menus and options reference 111
Options I Debugger
.. Be aware of the following with smart swapping:
112
Note
Inspectors
[XJ Show inherited
[X] Show methods
( ) Show decimal
( ) Show hex
( .) Show both
Program Heap Size
64 Kbytes
It's only meaningful to
increase heap size when
working with large data
models.
It swaps on any function call, even if the function generates no
screen output.
In some situations, the IDE screen might be modified without
being swapped; for example, if a timer-interrupt routine writes
to the screen.
If you set Display Swapping to Always, the debugger swaps
screens every time a statement executes. You should choose this
setting any time the IDE screen is likely to be overwritten by your
running program.
If you're debugging in dual-monitor mode (that is, you used the
Borland C++ command-line Id option or specified Dual monitor
mode on the Options I Environment I Startup dialog box), you can
see your program's output on one monitor and the Borland C++
screen on the other. In this case, Borland C++ never swaps screens
and the Display Swapping setting has no effect.
In the Inspectors check boxes, when Show Inherited is checked, it
tells the integrated debugger to display all member functions and
methods-whether they are defined within the inspected class or
inherited from a base class. When this option is not checked, only
those fields defined in the type of the inspected object are
displayed.
When checked, the Show Methods option tells the integrated
debugger to display member functions when you inspect a class.
Check the Show Decimal, Show Hex, or Show Both radio buttons
when you want to control how the values in inspectors are
displayed. Show both is on by default.
You can use the Program Heap Size input box to input how much
memory Borland C++ should assign a program when you debug
it. The actual amount of memory that Borland C++ gives to the
program equals the size of the executable image plus the amount
you specify here.
The default value for the program heap size is 64K. You may want
to increase this value if your program uses dynamically allocated
objects.
Borland C++ User's Guide
Directories
Options I Directories
The Options I Directories command lets you tell Borland C++
where to find the files it needs to compile, link, output, and
debug. This command opens the following dialog box containing
four input boxes:
J:I The Include Directories input box specifies the directory that
contains your include files. Standard include files are those
given in angle brackets in an #include statement (for
example, #include <myfile.h. These directories are also
searched for quoted Includes not found in the current directory.
Multiple directory names are allowed, separated by semicolons .
The Library Directories input box specifies the directories that
contain your Borland C++ startup object files (CO?OBJ), run-
time library files (.LIB files), and any other libraries that your
project may use. Multiple directory names are allowed,
separated by semicolons.
c The Output Directory input box specifies the directory that
stores your .OBJ, .EXE, and .MAP files. Borland C++ looks for
and writes files to that directory when doing a make or run,
and to check dates and times of .OBJs and .EXEs. If the entry is
blank, the files are stored in the current directory.
Borland C++ DOS IDE only II The Source Directories input box specifies the directories where
the Borland C++ integrated debugger looks for the source code
to libraries that do not belong to the open project (for example,
container class libraries). Multiple directories can be entered,
separated by semicolons. If the entry is blank, the current
directory is searched.
Use the following guidelines when entering directories in these
input boxes:
II If an input box supports multiple directory-path names, you
must separate them with a semicolon (;). You can use up to a
maximum of 127 characters (including whitespace).
II Whitespace before and after the semicolon is allowed but not
required .
.. Relative and absolute path names are allowed, including path
names relative to the logged position in drives other than the
current one. For example,
C:\C\LIBiC:\C\MYLIBSiA:\BORLANDC\MATHLIBSiA: .. \VIDLIBS
Chapter 3, Menus and options reference 113
Options I Resources
114
Resources
See Options I Transfer on
page 102 ..
Environment
You can customize edit
window colors in the
Options I Environment I
Highlight dialog box.
Preferences
Borland C++ DOS IDE only
Screen Size
(.) 25 1 i nes
( ) 43/50 1 i nes
The Options I Resources command in Borland C++ for Windows
sets several options for how resources are compiled and bound to
your application by the integrated resource compiler and resource
linker. In the Borland C++ DOS IDE, you can set these options by
modifying the Transfer program entry for the Resource Compiler.
The Target Windows Version group of radio buttons sets the
earliest version of Windows under which your application can
run. If you're using any features specific to Windows 3.1, you
should check Windows 3.10 and Above to ensure that your
application won't run under Windows 3.0.
The Pack Fastload Area check box causes the resource linker to
optimize how resources and segments are arranged in the
executable file. When this box is checked, the resource linker will
cause all data segments, nondiscardable code segments, and the
entry-point code segment to be preloaded and written to a
contiguous area in the executable file. No such optimizations will
be done if this box is unchecked.
The Options I Environment command lets you make
environment-wide settings. This command opens a menu that lets
you choose settings from Preferences, Editor, Mouse, Desktop,
Startup, and Colors.
In the Borland C++ for Windows environment, the Startup and
Colors options are not available. In addition, some of the other
selections are slightly different from their Borland C++
equivalents.
The Screen Size radio buttons let you specify whether your IDE
screen is displayed in 25 lines or 43/50 lines. One or both of these
buttons will be available, depending on the type of video adapter
in your PC.
When set to 25 lines (the default), Borland C++ uses 25 lines and
80 columns. This is the only screen size available to systems with
a monochrome display or Color Graphics Adapter (CGA).
Borland C++ User's Guide
Source Tracki'ng
(e) New window
( ) Current window
Comnand Set
( ) CUA
( ) Alternate
(e) Native
Auto Save
[ ] Editor Fil es
[X] Envi ronment
[X] Desktop
[X] Project
Borland C++ DOS IDE only
Borland C++ DOS IDE only
[ ] Save Old Messages
. Options I Environment I Preferences
If your PC has EGA or VGA, you can set this option to 43/50
lines. The IDE is displayed in 43 lines by 80 columns if you have
an EGA, or 50 lines by 80 columns if you have a VGA.
When stepping source or viewing the source from the Message
window, the IDE opens a new window whenever it encounters a
file that is not already loaded. Selecting Current Window causes
the IDE to replace the contents of the topmost Edit window with
the new file instead of opening a new Edit window.
The Command Set options allow you to choose either the CVA or
the alternate command set as your editor interface. You can also
select Native, which specifies that the CVA interface will be used
for the Borland C++ for Windows IDE, and Alternate will be used
for the Borland C++ IDE. For more information about the CVA
and alternate editor command sets, see Chapter 2, "IDE basics."
You can use the Auto Save check boxes to tell the IDE to save
changed files when there's a danger that you will lose work.
Editor Files includes all files in all open edit windows.
Environment is the environment-wide configuration file. Desktop
consists of window positions and sizes and history lists. Project
includes your project, auto dependency, and module settings.
Auto Save for all these options is invoked whenever you:
exit the IDE
shell to DOS
use a transfer item
choose any option under the Run menu
Auto Save for editor, desktop, and project files is invoked
whenever you:
close a project
open a new project
switch projects
When Save Old Messages is checked, Borland C++ saves the error
messages currently in the Message window, and messages from
future compiles are added. Messages are not saved from one
session to the next. By Borland C++ automatically clears
messages before a compile, a make, or a transfer that uses the
Message window.
The supplied Borland text editor font (BorlandTE) supports italic
and bold characters when you have syntax highlighting enabled.
Chapter 3, Menus and options reference
115
Options I Environment I Editor
116
Editor
Ed itor Opt ions
[X] Create backup files
[X] Insert mode
[X] Autoindent mode
[X] Use tab character
[X] Optimal fill
[X] Backspace unindents
[X] Cursor through tabs
[ ] Group undo
[X] Persistent blocks
[ ] Overwrite blocks
[X] Syntax highlighting
If you choose Editor from the Environment menu, these are the
options you can pick from:
When Create Backup Files is checked (the default), Borland
C++ automatically creates a backup of the source file in the Edit
window when you choose File I Save and gives the backup file
the extension .BAK.
When Insert Mode is not checked, any text you type into Edit
windows overwrites existing text. When the option is checked,
text you type is inserted (pushed to the right). Pressing Ins
toggles Insert mode when you're working in an Edit window.
When Autoindent Mode is checked, pressing Enter in an Edit
window positions the cursor under the first nonblank character
in the preceding nonblank line. This can be a great aid in typing
readable program code. .
When Use Tab Character is checked, Borland C++ inserts a true
tab character (ASCII 9) when you press Tab. When this option is
not checked, Borland C++ replaces tabs with spaces. If there are
any lines with characters on them prior to the current line, the
cursor is positioned at the first corresponding column of
characters following the next whitespace found. If there is no
"next" whitespace, the cursor is positioned at the end of the
line. After the end of the line, each Tab press is determined by
the Tab Size setting.
When you check Optimal Fill, Borland C++ begins every
autoindented line with the minimum number of characters
possible, using tabs and spaces as necessary. This produces
lines with fewer characters than when Optimal Fill is not
checked.
When Backspace Unindents is checked (which is the default)
and the cursor is on a blank line or the first nonblank character
of a line, the Backspace key aligns (outdents) the line to the
previous indentation level. This option is only effective when
Cursor Through Tabs is also selected.
When you check Cursor Through Tabs, the arrow keys will
move the cursor space by space through tabs; otherwise the
cursor jumps over tabs.
When Group Undo is unchecked, choosing Edit I Undo reverses
the effect of a single editor command or keystroke. For
example, if you type ABC, it will take three Undo commands to
delete C, then B, then A.
Borland C++ User's Guide
ITab Size 81
Options I Environment I Editor
If Group Undo is checked, Undo reverses the effects of the
previous command and all immediately preceding commands
of the same type. The types. of commands that are grouped are
insertions, deletions, overwrites, and cursor movements. For
example, if you type ABC, one Undo command deletes ABC.
For the purpose of grouping, inserting a carriage return is
considered an insertion followed by a cursor movement. For
example, if you press Enter and type ABC, choosing Undo once
will delete the ABC, and choosing Undo again moves the cursor
to the new carriage return. Choosing Edit I Redo at that point
would move the cursor to the following line. Another Redo
would insert ABC. (See page 53 for more information about
Undo and Redo.)
When Persistent Blocks is checked (the default), marked blocks
behave as they always have in Borland's C and C++ products;
that is, they remain marked until deleted or unmarked (or until
another block is marked). With this option unchecked, moving
the cursor after a block is selected deselects the entire block of
text.
111 When Overwrite Blocks is checked and Persistent Blocks is
unchecked, marked blocks behave differently in these
instances:
1. Pressing the Del key or the Backspace key clears the entire
selected text.
2. Inserting text (pressing a character or pasting from
clipboard) replaces the entire selected text with the inserted
~ r t .
When Syntax Highlighting is checked, you can control the
colors in an Edit window of various elements in your C or C++
code. In the DOS IDE, you can select these colors in the
Options I Environment I Colors dialog box. In the Windows IDE,
use the Options I Environment I Highlight dialog box.
When you press Tab, Borland C++ moves the cursor to the next
tab stop. The Tab Size input box allows you to dictate how many
characters to move for each tab stop. Legal values are 2 through,
16; the default is 8.
To change the way tabs are displayed in a file, just change the tab
size value to the size you prefer. Borland C++ redisplays all tabs
in that file in the size you chose. You can save this new tab size in
your configuration file by choosing Options I Save Options.
Chapter 3, Menus and options reference 117
Options I Environment I Editor
IDefault Extension cpp I
Highlight
Figure 3.25
The Highlighting dialog box
118
The Default Extension input box lets you tell Borland c++ which
extension to use as the default when compiling and loading your
source code. The IDE uses the default extension to name new files
and in file-selection dialog boxes.
You can boldface, italicize, underline, or change the color of code
elements. Choose Options I Environment I Highlight and the
Highlighting dialog box appears.
The list box on the left lists the elements of C and C++ code.
Coloring your text
T<? change the color of an element, follow these steps:
1. Select the element you want to change in the Element list box,
or click a sample of that element in the code sample.
2. Select the colors you want in the Color dialog box.
The current foreground color is marked with the letters FG;
the current background color is marked with the letters BG. If
the foreground and background colors are the same, you'll see
the letters FB on the color square.
Borland C++ User's Guide
To boldface or italicize text,
the editor must use the
Bor/andTE font. To change
fonts, choose Options I Editor
and select the Font option
you want.
Options I Environment I Highlight
To select a foreground color with your mouse, click it. To
select the color with your keyboard, press Tab until the
Color matrix is selected, use the arrow keys to move around
the Color matrix, and when you're on the color of your
choice, press F .
To select a background color with your mouse, click it with
the right mouse button. To select the color with your
keyboard, press Tab until the Color matrix is selected, use
the arrow keys to move around the Color matrix, and when
you're on the color of your choice, press B.
As soon as you select a color, you'll see the results reflected
in the sample code.
3. Choose OK .
. Using the Windows system colors
Windows uses a window-background color and a text color, and
most Windows applications use these same colors. To change the
Windows system colors, use the Control Panel in the Program
Manager.
You can choose to use the Windows system colors with the
Highlighting dialog box. To use the Windows system foreground
color for an element, follow these steps:
1. From the Highlighting dialog box, select the element in the
Element list box.
2. Check the Default FG option.
Follow the same steps to change the background color, except
choose the Default BG option.
Changing text attributes
To select the attribute of an element, follow these steps:
1. From the Highlighting dialog box, select the element in the
Element list box.
2. Select the attribute from the Attributes options.
As soon as you make an attribute selection, you'll see it reflected
in the sample code window.
Chapter 3, Menus and options reference 119
Options I Environment I Highlight
120
Right Mouse Button
( ) Nothing
(e) Topic search
( ) Search
( ) Search again
( ) Replace
( ) Go to cursor
( ) Breakpoint
( ) Inspect
( ) Evaluate
( ) Add watch
You can also select an element to change by simply clicking an
occurrence of it in the sample code window. For example, if you
click the reserved word return, you'll see that the element
Reserved Word is selected in the Element list box. Changing
colors or attributes' will change all the reserved words in the
sample code.
Remember that you must check Options I Environment I Editor I
Syntax Highlighting to enable syntax highlighting.
When you choose Mouse from the Environment menu, the Mouse
Options dialog box is displayed, which contains all the settings
for your mouse. These are the options available to you:
The Right Mouse Button radio buttons determine the effect of
pressing the right button of the mouse (or the left button, if the
Reverse Mouse Buttons option is checked). Topic Search is the
default.
Here's a list of what the right button would do if you choose
something other than Nothing:
Topic Search
Search
Search again
Replace
Go to Cursor
Breakpoint
Inspect
Evaluate
Add Watch
Same as Help I Topic Search
Same as Search I Find
Same as Search I Search Again
Same as Search I Replace
Same as Run I Go To Cursor
Same as Debug I Toggle Breakpoint
Same as Debug I Inspect
Same as Debug I Evaluate
Same as Debug I Watches I Add Watch
In the Borland C++ for Windows IDE, which does not support
integrated debugging, the options from Go to Cursor and below
are not available. ,The Borland C++ for Windows environment,
however, has an additional option, Browse, which sets the right
mouse button to have the same effect as selecting Browse I Symbol
from the menu.
Borland C++ DOS IDE only . The remaining mouse options, Mouse Double Click and Reverse
Mouse Buttons, are available in the Borland C++ DOS IDE only.
In the Windows IDE, you can set these options in the Windows
Control Panel.
Mouse Double Click
Fast Test Slow
~ .... -
In the Mouse Double Click box, you can change the slider control
bar to adjust the double-click speed of your mouse by using the
arrow keys or the mouse.
Borland C++ User's Guide
Options I Environment I Mouse
ibL Moving the scroll box closer to Fast means Borland C++ requires
a shorter time between clicks to recognize a double click. Moving
the scroll box closer to Slow means Borland C++ still recognizes a
double click even if you wait longer between clicks.
[ ] Reverse Mouse Buttons
Desktop
Desktop Preferences
[X] History lists
[ ] Cl i pboard
[ ] Watch expressions
[ ] Breakpoi nts
[X] Open windows
[X] Closed windows
If you want to experiment with different settings, you can
double-click the Test button above the scroll bar. When you
successfully double-click the bar it becomes highlighted.
When Reverse Mouse Buttons is checked, the active button on
your mouse is the rightmost one instead of the leftmost. Note,
however, that the buttons won't actually be switched until you
choose the OK button.
Depending on how you hold your mouse and whether you're
right- or left-handed, the right mouse button might be more
comfortable to use than the left.
The Desktop Preferences dialog box lets you set whether history
lists, the contents of the Clipboard, watch expressions,
breakpoints, and open and closed windows are saved across
sessions. History lists and open windows are saved by default;
because watch expressions and breakpoints may not be
meaningful across sessions, they are not saved by default, nor are
windows that you have closed. You can change these defaults by
unchecking or checking the respective options.
The Borland C++ for Windows IDE does not offer the Watch
expressions and Breakpoints options. However, it provides an
additional set of radio buttons to control the appearance of the
SpeedBar. You may turn the SpeedBar off entirely, or have it
appear as a pop-up, a vertical bar, or a horizontal bar. For more
information about the SpeedBar, see Chapter 2, "IDE basics."
Startup The Startup Options dialog box lets you set startup options for the
Borland C++ DOS IDE.
Chapter 3, Menus and options reference 121
Options I Environment I Startup
Borland C++ DOS IDE only
Figure 3.26
The Startup Options dialog
box
122
Video Startup Options
[ ] Save entire palette
[ ] Dual monitor mode
[ ] Snow checking
Video Mode
(e) Auto detect
( ) Color (80 column)
( ) Black & White / LCD
( ) Monochrome
swaP.il e Dri ve
Use E tended Memory
Use S Memory
When Borland C++ switches between graphics and text mode
to run or debug a graphics program, the video display may
become corrupted unless the entire EGA or VGA video palette
is saved in a separate buffer during the switch. Save entire
palette should be left unchecked if you will not be running or
debugging graphics programs, since saving the palette slows
down execution speed .
.. Dual monitor mode lets you run your program on one monitor
while debugging in the IDE on another monitor .
.. Snow checking tells Borland C++ to check for video "snow."
This usually occurs only on older CGA video adapters. Disable
this option if your display driver doesn't have a "snow"
problem.
Auto detect (the default) tells Borland C++ to check your
hardware on startup and set its video mode automatically
Color specifies that Borland C++ should always run
CGA/EGA/VGA/XGA monitors in color mode .
.. Black & White / LCD tells Borland C++ to run
CGA/EGA/VGA/XGA monitors"always in black-and-white
mode. This mode should be used for most laptop LCD
monitors.
Monochrome tells Borland C++ to run always in monochrome
mode.
Swap File Drive lets you specify a disk drive to use as a swap file
in the event that Borland C++ runs out of memory while
compiling or linking your project. If you have a RAM drive, you
should specify this as your swap drive, to improve speed.
Use Extended Memory allows you to tell Borland C++ how much
extended memory (in Kilobytes) to reserve for its use.
Borland C++ User's Guide
Colors
Borland C++ DOS IDE only
In Borland C++ for Windows,
you can use the Options I
Environment I Highlight dialog
box to customize the colors
used in edit windows. You
can set other colors in the
Windows Control Panel.
Figure 3.27
The Colors dialog box
Save
Options I Environment I Colors
Use EMS Memory allows you to tell Borland C++ how many
expanded memory (EMS) pages to reserve for its use when
swapping.
The Colors dialog box allows you to set your color preferences for
each component of the DOS IDE. Select any Group and any Item
within that Group, and the available Foreground and Background
colors appear in the respective sections of the dialog box. A
sample of the currently selected scheme appears in the Item Color
box. To change the default color for that item, select your
preferences from the Foreground and Background palettes. When
you have modified all the items you wish to change, select OK to
exit and save your changes. To exit without recording any
changes, select Cancel.
You can select colors for syntax elements under Item for the Edit
Window group. If you checked Syntax Highlight in the Options I
Environment I Editor dialog box, those elements appear in the
colors you selected. (See page 118 for more information about
syntax elements.)
Pop-up Menus
Edit Window
Output Wi ndow
Message Wi ndow
Watch Wi ndow
Modal Help
Help
Status Line
Proj ect Wi ndow
I nspector Wi ndow
Dialog Window
Dial Controls
The Options I Save command brings up a dialog box that lets you
save settings you've made in both the Find and Replace dialog
boxes (off the Search menu) and in the Options menu (which
includes all the dialog boxes that are part of those commands) for
IDE, Desktop, and Project items. Options are stored in three files,
which represent each of these categories. If it doesn't find the files,
Borland C++ looks in the Executable directory (from which
BC.EXE is run) for the same file.
Chapter 3, Menus and options reference
123
Window
Window menu
Size/Move
The Window menu contains window-management commands.
Most of the windows you open from this menu have all the
standard window elements like scroll bars, a close box, and zoom
boxes. Refer to page 30 for information on these elements and
how to use them.
The Windows IDE Window menu differs somewhat from that of
DOS IDE. Although not as many window-management
commands are on the Borland C++ for Windows Window menu,
the same functionality exists. If you know how to use Windows,
you'll know how to manage windows within the Borland C++ for
Windows IDE; just use the same commands you'd use in other
Windows applications.
Bor/and c++ DOS IDE only Choose Window I Size/Move to change the size or position of the
Alternate active window.
[gill [[] When you choose this command, the active window moves in
response to the arrow keys. When the window is where you want,
press Enter. You can also move a window by dragging its title bar.
Zoom
Bor/and c++ DOS IDE only
Alternate
[[]
Tile
If you press Shift while you use the arrow keys, you can change
the size of the window. When it's the size you want, press Enter. If
a window has a,resize comer, you can drag that corner or any
other corner to resize it.
Choose Window I Zoom to resize the active window to the
maximum size. If the window is already zoomed, you can choose
this command again to restore it to its previous size. You can also
double-click anywhere on the top line (except where an icon
appears) of a window to zoom or unzoom it.
CUA Choose Window I Tile to tile all your open windows.
I Shift I[[]
124 Borland C++ User's Guide
Window I Cascade
Cascade
CVA Choose Window I Cascade to stack all open windows.
I Shift I[E]
Arrange Icons
Next
Borland C++ DOS IDE only
CVA
@!ill[ill
Alternate
[ill
Close
Borland C++ DOS IDE only
CVA
@!ill[E]
Alternate
[][Jill]
Close All
Message
In Borland C++, you can
display transfer program
output in the Message
window.
Choosing Window I Arrange Icons will rearrange any icons on the
Borland c++ for Windows desktop so they are evenly spaced,
beginning at the lower left corner of the desktop.
Choose Window I Next to make the next window active, which
makes it the topmost open window.
Choose Window I Close to close the active window. You can also
click the close box in the upper left corner to close a window.
In Borland C++, choose Close All to close all windows and clear
all history lists. This command is useful when you're starting a
new project. In Borland C++ for Windows, Close All closes all
open windows on the Borland C++ for Windows desktop. History
lists are not saved.
Choose Window I Message to open the Message window and
make it active. The Message window displays error and warning
messages, which you can use for reference, or you can select them
and have the corresponding location be highlighted in the edit
Chapter 3, Menus and options reference 125
Window I Message
Output
window. When a message refers to a file not currently loaded,
you can press the Spacebar to load that file. When an error is
selected in the Message window, press Enter to show the location
of the error in the edit window and make the edit window active
at the point of error.
To close the window, click its close box or choose Window I Close.
Borland C++ DOS IDE only Choose Window I Output to open the Output window and make
it active. The Output window displays text from any DOS
command-line and any text (but no graphics) generated by your
program.
Watch
The Output window is handy while debugging because you can
view your source code, variables, and output all at once. This is
especially useful when you've set the Options I Environment
dialog box to a 43/50 line display and you are running a standard
25-line mode program. In that case, you can see almost all of the
program output and still have plenty of lines to view your source
code and variables.
If you would rather see your program's text on the full screen-or
if your program generates graphics-choose the Window I User .
Screen command instead.
To close the window, click its close box or choose Window I Close.
Borland C++ DOS IDE only Choose Window I Watch to open the Watch window and make it
active. The Watch window displays expressions and their
126
. changing values so you can keep an eye on how your program
evaluates key values.
You use the commands in the Debug I Watches pop-up menu to
add or remove watches from this window. Refer to the section on
this menu for information on how to use the Watch window (page
75).
To close the window, click its close box or choose Window I Close.
Borland C++ User's Guide
User Screen
Borland C++ DOS IDE only
CUA
I Shift ImJ
Alternate
~ m J
Register
Window I User Screen
Choose Window I User Screen to view your program's full-screen
output. If you would rather see your program output in a Borland
C++ window, choose the Window I Output command instead.
. Clicking or pressing any key returns you to the IDE.
Borland C++ DOS IDE only Choose Window I Register to open the Register window and make
it active.
Project
Project Notes
The Register window displays CPU registers and is used most
often when debugging inline ASM and T ASM modules in your
project.
To close the window, click its close box or choose Window I Close.
Choose Window I Project to open the Project window, which lets
you view the list of files you're using to create your program.
Borland C++ DOS IDE only Choose Window I Project Notes to write down any details, make
to-do lists, or l i s ~ any other information about your project files.
List All
Borland C++ DOS IDE only
Choose Window I List All to see a list of all the windows you've
opened. The list contains the names of all files currently open as
well as any of the last eight files you've opened in an edit window
but have since closed. A recently closed file appears in the list
prefixed with the word closed.
When you choose an already open file from the list, Borland C++
brings the window to the front and makes it active. When you
choose a closed file from the list, Borland C++ reopens the file in
an edit window in the same size' and location as when the
window was closed. The cursor is positioned at its last location.
Chapter 3, Menus and options reference 127
Window I List All
Help menu
Borland C++ DOS IDE only
When getting help in a
dialog box or menu, you
cannot resize the window or
copy to the clipboard. In this
instance, Tab takes you to
dialog-box controls, not the
next keyword.
128
In Borland c++ for Windows, you can see a list of recently closed
files at the bottom of the File menu, and you can see a list of open
windows at the bottom of the Window menu. Choosing a closed
file name reopens the file in a new edit window. Choosing an
open window makes that window active.
The Help menu gives you access to online help in a special
window. There is help information on virtually all aspects of the
IDE and Borland C++. (Also, one-line menu and dialog box hints
appear on the status line whenever you select a command.)
To open the Help window, do one of these actions:
Press F1 at any time (including from any dialog box or when
any menu command is selected).
II When an edit window is active and the cursor is positioned on
a word, press Ctrl+F1 to get language Help on that word .
Click Help whenever it appears on the status line or in a dialog
box.
To close the Help window, press Esc, click the close box, or choose
Window I Close. You can keep the Help window onscreen while
you work in another window unless you opened the Help
window from a dialog box or pressed F1 when a menu command
was selected.
Help screens often contain keywords (highlighted text) that you
can choose to get more llformation. Press Tab to move to any
keyword; press Enter to get more detailed help. (As an alternative,
move the cursor to the highlighted keyword and press Enter.) With
a mouse, you can double-click any keyword to open the Help text
for that item.
You can also cursor around the Help screen and press Ctrl+F1on
any word to get help. If the word is not found, an incremental
search is done in the index and the closest match is displayed.
When the Help window is active, you can copy from the window
and paste that text into an edit window. You do this the same as
you would in an edit window: Select the text first, choose Edit I
Copy, move to an edit window, then choose Ed}t I Paste.
Bor/and c++ User's Guide
Help
To select text in the Help window, drag across the desired text or,
when positioned at the start of the press f-, I,.!- to
mark a block.
You can also copy preselected program examples from Help
screens by choosing the Edit I Copy Example command.
10 Borland C++ for Windows uses the Windows Help system. See
your Windows manual for more information on the Windows
Help system.
Contents
Borland C++ DOS IDE only
Index
I Shift IffiJ
Borland C++ DOS IDE only
You can also tab to a
keyword to select it.
Topic Search

The Help I Contents command opens the Help window with the
main table of contents displayed. From this window, you can
branch to any other part of the help system.
You can get help on Help by pressing F1 when the Help window
is active. You can also reach this screen by clicking on the status
.
The Help I Index command displays a full list of Help keywords
(the special highlighted text in Help screens that let you quickly
move to a related screen).
You can scroll the list or you can incrementally search it by
pressing letters from the keyboard. For example, to see what's
available under "printing," you can type p r i. When you type p,
the cursor jumps to the first keyword that starts with p. When you
type r, the cursor moves to the first keyword that starts with pro
When you type i, the cursor moves to the first keyword that starts
with pri, and so on.
When you find a keyword that interests you, choose it by
cursoring to it and pressing Enter. (You can also double-click it.)
The Help I Topic Search command displays language Help on the
currently selected item.
To get language Help, position the cursor on an item in an edit
window and choose Topic Search. You can get help on things like
function names (printf, for example), header files, reserved words,
Chapter 3, Menus and options reference 129
Help I Previous Topic
Previous Topic
and so on. If an item is not in the Help system, the Help index
displays the closest match.
Borland C++ DOS IDE only The Help I Previous Topic command opens the Help window and
@O[IT] redisplays the text you last viewed.
Help on Help
Borland C++ DOS IDE only
Active File
Borland C++ DOS IDE only
About
130
Borland C++ lets you back up through 20 previous Help screens.
You can also click on the status line to view the last Help screen
displayed.
The Help I Help on Help command opens up a text screen that
explains how to use the Borland C++ Help system. If you're
already in Help, you can display this screen by pressing Ft.
The Help I Using Help option in Borland C++ for Windows is very
similar to the Help on Help command in Borland C++.
The Help I Active File command displays a dialog box that lets
you select the Help file you want the IDE to use. Theses are the
topics you can get help on:
IDE, C++ language, and Windows API
ObjectWindows API
Turbo Vision API
When you choose this command, a dialog box appears that shows
you copyright and version information for Borland C++ or
Borland C++ for Windows. Press Esc or click OK (or press Enter) to
close the box.
Borland C++ User's Guide
c H A
p
T E R
4
Managing multi-file projects
Since most programs consist of more than one file, having a way
to automatically identify those that need to be recompiled and
linked would be ideal. Borland C++'s built-in Project Manager
does just that and more.
The Project Manager allows you to specify the files belonging to
the project. Whenever you rebuild your project, the Project
Manager automatically updates the information kept in the
project file. This project file includes
Ell all the files in the project
where to find them on the disk
the header files for each source module
which compilers and command-line options need to be used
when creating each part of the program
where to put the resulting program
I!I code size, data size, and number of lines from the last compile
Using the Project Manager is easy. To build a project,
g pick a name for the project file (from Project I Open Project)
add source files using the Project I Add Item dialog box
tell Borland C++ to Compile I Make
Then, with the project-management commands available on the
Project menu, you can
add.or delete files from your project
Chapter 4, Managing multi-file projects 131
set options for a file in the project
view included files for a specific file in the project
All the files in this chapter are Let's look at an example of how the Project Manager works.
in the EXAMPLES directory.
Sampling the Project Manager
These names can be the
some (except for the exten-
sions), but they don't have to
be. The nome of your
executable file (and any
mop file produced by the
linker) is based on the project
files nome.
132
Suppose you have a program that consists of a main source file,
MYMAIN.CPP, a support file, MYFUNCS.CPP, that contains
functions and data referenced from the main file, and myfuncs.h.
MYMAIN.CPP looks like this:
#include <iostream.h>
#include "myfuncs.h"
main(int argc, char *argv[])
{
char *l'U
if (argc > 1)
s=argv[l]j
else
s="the universe"j
cout GetString() s "\n"j
MYFUNCS.CPP looks like this:
char ss[] = "The restaurant at the end of "j
char *GetString(void)
{
return SSj
And myfuncs.h looks like this:
extern char *GetString(void)j
These files make up the program we'll describe to the Project
Manager.
The first step is to tell Borland C++ the name of the project file
you're going to use: Call it MYPROG.PRJ. The name of the project
file is not the same as the name of the main file (MYMAIN.CPP).
And in this case, the executable file will be MYPROG.EXE (and if
you choose to generate it, the map file will be MYPROG.MAP).
Borland C++ User's Guide
If the project file you load is
in another directory, the
current directory is set to
where the project file is
loaded.
The SpeedBar also has
buttons to perform these
common operations.
You can change the file-
name specification with the
Name input box: *.CPP is the
default.
If you copy the wrong file to
the Project window, press Esc
to return to the Project
window, then Del, or click the
Delete Item button on the
SpeedBar to remove the
currently selected file.
Go to the Project menu and choose Open Project. This opens the
Open Project File dialog box, which lists of all the files in the
current directory with the extension .PRJ. Since you're starting a
new file, type in the name MYPROG in the Open Project File input
box.
Once a project is opened, the Add Item, Delete Item, Local
Options, and Include Files options are enabled on the Project -
menu.
You can keep your project file in any directory; to put it some-
where other than the current directory, just specify the path as
part of the file name. (You must also specify the path for source
files if they're in different directories.) Note that all files and corre-
sponding paths are relative to the directory the project file is
loaded from. After you enter the project file name, you'll see a
Project window.
The Project window contains the current project file naIIl:e
(MYPROG). Once you indicate which files make up your project,
you'll see the name of each file and its path. When the project file
is compiled, the Project window also shows the number of lines in
the file and the amount of code and data in bytes generated by the
compiler.
The status line at the bottom of the screen shows which actions
can be performed at this point: F1 gives you Help, Ins adds files to
the Project, Del deletes a file from the Project, etr/+o lets you select
options for a file, Spacebar lets you view information about the
include files required by a file in the Project, Enter opens an editor
window for the currently selected file, and F10 takes you to the
main menu. You can also click on any of these items with the
mouse to take the appropriate action. Press Ins now to add a file to
the project list.
The Add to Project List dialog box appears; this dialog box lets
you select and add source files to your project. The Files list box
shows all files with the .CPP extension in the current directory.
(MYMAIN.CPP and MYFUNCS.CPP both appear in this list.)
Three action buttons are available: Add, Done, and Help.
Since the Add button is the default, you can place a file in the
Project window by typing its name in the Name input box and
pressing Enter or by choosing it in the Files list box and choosing
OK. You can also search for a file in the Files list box by typing the
first few letters of the one you want. In this case, typing my should
take you right to MYFUNCS.CPP. Press Enter. You'll see that
Chapter 4, Managing multi-file projects 133
The Add button commits
your change; pressing Esc
when you're in the dialog
box closes the dialog box.
You can also view your
output Ly choosing
Wind.:'w I Output .
. Borland C++ COS IDE only
For more information on .PRJ
and .DSK files, refer to the
section "Configuration and
project files, " in Chapter 2.
You can specify a project to
load on the DOS command
line like this: Be myprog. prj.
134
MYFUNCS is added to the Project window and then you're
returned to the Add Item dialog box to add another file. Go ahead
and add MYMAIN.CPP. Borland C++ will compile files in the
exact order they appear in the project.
Close the dialog box and return to the Project window. Notice
that the Lines, Code, and Data fields in the Project window show
n/ a. This means the information is not available until the modules
are actually compiled.
After you've set all compiler options and directories, Borland C++
knows everything it needs about how to build the program called
MYPROG.EXE using the source code in MYMAIN.CPP,
MYFUNCS.CPP, and myfuncs.h. Now you'll actually build the
project.
Choose Compile I Make or click the Make button on the SpeedBar
to make your project. Choose Run I Run to run it.
To view your output, choose Window I User Screen, then press
any key to return to the IDE.
When you leave the IDE, your project file is automatically saved
on disk; you can disable this by unchecking Project in the
Preferences dialog box (Options I Environment).
The saved project consists of two files: the project file {.PRDand
the desktop file (.DSK). The project file contains the information
required to build the project's related executable. The build
information consists of compiler options,
INCLUDE/LIB/OUTPUT paths, linker options, make options,
and transfer items. The desktop file contains the state of all
windows at the last time you were using the project.
The next time you use Borland C++, you can jump right into your
project by reloading the project file. Borland C++ automatically
loads a project file if it is the only .PRJ file in the current directory;
otherwise the default project and desktop (TCDEF.* and
TCDEFW. *) are loaded. Since your program files and their
corresponding paths are relative to the project file's directory, you
can work on any project by moving to the project file's directory
and bringing up Borland C++. The correct file will be loaded
automatically. If no project file is found in the current directory,
the default project file is loaded.
Borland C++ User's Guide
Error tracking
Changing these files makes
them out of date with their
object files. Doing a make
. recompiles them.
Stopping a make
Syntax errors in
multiple source
files
Syntax errors that generate compiler warning and error messages
in multi-file programs can be selected and viewed from the
Message window.
To see this, let's introduce some syntax errors into the two files,
MYMAIN.CPP and MYFUNCS.CPP. From MYMAIN.CPP,
remove the first angle bracket in the first line and remove the c in
char from the fifth line. These changes will generate five errors
and two warnings in MYMAIN.
In MYFUNCS.CPP, remove the first r from return in the fifth line.
This change will produce two errors and one warning.
Since you want to see the effect of tracking in multiple files, you
need to modify the criterion Borland C++ uses to decide when to
stop the make process. This is done by setting a radio button in
the Make dialog box (Options I Make).
You can choose the type of message you want the make to stop on
by setting one of the Break Make On options in the Make dialog
box (Options I Make). The default is Errors, which is normally the
setting you'd want to use. However, you can have a make stop
after compiling a file with warnings, errors, or fatal errors, or have
it stop after all out-of-date source modules have been compiled.
The usefulness of each of these modes is determined by the way
you like to fix errors and warnings. If you prefer to fix errors and
warnings as soon as you see them, you should set Break Make On
to Warnings or maybe to Errors. If you prefer to get an entire list
of errors in all the source files before fixing them, set the radio
button to Fatal Errors or to Link. To demonstrate errors in
multiple files, choose Fatal Errors in the Make dialog box.
Since you've already introduced syntax errors into MYMAIN.CPP
and MYFUNCS.CPP, choose Compile I Make to "make the
project." The Compiling window shows the files being compiled,
the number of errors and warnings in each file, and the total for
the make. Press any key when the Errors: Press any key message
flashes.
Chapter 4, Managing multi-file projects 135
Your cursor is now positioned on the first error or warning in the
Message window. If the file the message refers to is in the editor,
the highlight bar in the edit window shows you where the
compiler detected a problem. You can scroll up and down in the
Message window to view the different messages.
Note that there is a "Compiling" message for each source file that
was compiled. These messages serve as file boundaries, separat-
ing the messages generated by each module and its include files.
When you scroll to a message generated in a different source file,
the edit window tracks only in files currently loaded.
Moving to a message that refers to an unloaded file causes the
edit window's highlight bar to turn off. Press Spacebar to load that
file and continue tracking, and the highlight bar reappears. If you
choose one of these messages (that is, press Enter when positioned
on it), Borland C++ loads- the file the message references into an
edit window and places the cursor on the error. If you then return
to the Message window, tracking resumes in that file.
The Source Tracking options in the Preferences dialog box
(Options I Environment) help you determine which window a file
is loaded into. You can use these settings when you're message
tracking and debug stepping. .
Both Previous Error and Next Error (on the Search menu) are
affected by the Source Tracking settif1g. These commands will
always find the next or previous error and loads the file using the
method specified by Source Tracklng.
Saving or deleting
136
messages Normally, whenever you start to make a project, the Message
window is cleared out to make room for new messages. Some-
times, however, it is desirable to keep messages around between
makes.
Consider the following example: You have a project that has
many source files and your program is set to stop on Errors. In
this case, after compiling many files with warnings, one error in
one file stops the make. You fix that error and want to find out if
the compiler will accept the fix. But if you do a make or compile
again, you lose your earlier warning messages. To avoid this,
check Save Old Messages in the P r e f e r e ~ c e s dialog box (Options I
Environment). This way the only messages removed are the ones
that result from the files yo.u recompile. ':fhus, the old messages
Borland C++ User's Guide
Autodependency
checking
for a given file are replaced with any new messages that the com-
piler generates.
You can always get rid of all your messages by choosing
Compile I Remove Messages, which deletes all the current
messages. Unchecking Save Old Messages and running another
make will also get rid of any old messages.
When you made your previous project, you dealt with the most
basic situation: a list of C++ source file names. The Project
Manager provides you with a lot of power to go beyond this
simple situation.
The Project Manager collects autodependency information at
compile time and caches these so that only files compiled outside
the IDE need to be processed. The Project Manager can autOll1at-
ically check dependencies between source files in the project list
(including files they themselves include) and their corresponding
object files. This is useful when a particular C++ source file
depends on other files. It is common for a C++ source to include
several header files (.h files) that define the interface to external
routines. If the interface to those routines changes, you'll want the
file that uses those routines to be recompiled.
If you've checked the Auto-Dependencies option (Options I Make),
Make obtains time-date stamps for all.CPP files and their in-
cluded files. Then Make compares the date/time information of
all these files with their date/time at last compile. If any
date/time is different, the source file is recompiled.
If the Auto-Dependencies option is unchecked, the .CPP files are
checked against .OBJ files. If earlier .CPP files exist, the source file
is recompiled.
When a file is compiled, the IDE's compiler and the command-line
compiler put dependency information into the .OBJ files. The
Project Manager uses this to verify that every file used to build
the .OBJ file is checked for time and date against the time and date
information in the .OBJ file. The .CPP source file is recompiled if
the dates are different.
That's all there is to dependencies. You get the po-wer of more
traditional makes while avoiding long dependency lists.
Chapter 4, Managing multi-file projects 137
Using different file translators
Borland C++ for Windowss
Project Manager doesn't use
other file translators but does
support other project-item
options.
So far you've built projects that use Borland C++ as the only
language translator. Many projects consist of both C++ code and
assembler code, and possibly code written in other languages. It
would be nice to have some way to tell Borland C++ how to build
such modules using the dependency checks just described. With
the Project Manager, you don't need to worry about forgetting to
rebuild those files when you change some of the source code, or
. about whether you've put them in the right directory, and so on.
For every source file you included in the list in the Project
window, you can specify
Borland C++ DOS IDE only _ which program (Borland C++, TASM, and so on) to use to build
the target file
II which command-line options to give that program
Borland C++ DOS IDE only II whether the module is an overlay
Changing
translator options
138
_ what to call the resulting module and where it will be placed
(this information is used by the Project Manager to locate files
needed for linking)
whether the module contains debug information
whether the module gets included in the link
By default, the Project Manager uses the IDE's compiler for each
.C or .CPP module, using no command-line override options,
using the Output directory for output, assuming that the module
is not an overlay, and assuming that debug information is not to
be excluded. The Project Manager uses Turbo Assembler for .ASM
modules and the Resource Compiler for .RC and .RES files.
The Resource Compiler takes several optional command-line
arguments. For example, the -31 option will mark the application
as requiring Windows 3.1, which can be useful if you are using
Windows 3.1-specific features.
To change the options that the Project Manager passes to the
Resource Compiler, choose Options I Transfer and select Resource
Compiler. Move to the Command Line input box. The $RC
transfer macro takes care of the required arguments, but you can
add any optional arguments before it. For example, if you wanted
Borland C++ User's Guide
Changing file
translators
Assigning a new
file translator
Note that Borland Resource
Compiler was added to the
list of Program Titles.
There s only a single entry for
Resource Compiler.
There are several Windows
projects in the EXAMPLES
directory.
to pass the -31 option to the Resource Compiler, you might use
-31 $RC.
Borland C++ comes with both the Borland and Microsoft
Resource Compilers. The Project Manager defaults to using the
Microsoft Resource Compiler, but you can easily change your
projects to use the Borland Resource Compiler. Choose Options I
Transfer, select Resource Compiler, and press OK. Program Path
is set to RC. Change it to BRC and choose OK.
Normally the Project Manager uses the translator listed in the
Resource Compiler transfer item to both compile .RC resource
scripts and link .RES bLl1ary resource files. This behavior matches
the way that the Resource Compiler (RC or BRC) does both jobs.
However, Borland C++ also includes separate a separate Resource
Compiler (BRCC) and Resource Linker (RLINK). Since using
these tools separately is often faster than letting the Resource
Compiler do it, you might want to set up your projects to use the
tools separately. To do so, follow these steps:
1. You need to define both the Resource Compiler and Resource
Linker as transfer items. Choose Options I Transfer, select
Resource Compiler, and choose Edit. Change the Program
Title to Borland Resource Compiler and the Program Path to
BRCC. You can leave the Command Line as $RC. Choose New.
2. You'll be returned to the Options I Transfer dialog box. Select
Resource Compiler and choose Edit. Don't change the
Program Title or Command Line, but change Program Path to
RLINK. Choose Modify.
The Program Title must stay Resource Compiler. The Project
Manager looks for that title when dealing with .RC and .RES
files.
3. Once again you're returned to the Options I Transfer dialog
box. Press Esc or choose Cancel.
4. Open a project that has an .RC file. Select that file and press
Ctr/+O to bring up the Local Options dialog box. Notice that the
Project File Translators list now has Borland Resource
Compiler and Resource Compiler. Move to that list and select
Borland Resource Compiler. Use the Command Line Options
Chapter 4, Managing multi-file projects 139
input box to specify any additional command-line options,
such as -31.
The .RC file is now compiled with BRCC and linked with RLINK.
The Project Manager will apply the same criteria to the .RC file
when deciding whether to recompile the module during a make
as it will to all the modules compiled with the IDE compiler.
Using the Project Manager to build Windows
applications
Don'tput .h, .BMP, .ICO, or
DLG files in your projects.
Instead, the project's .RC or
.RES file should include them.
Table 4.1
Project Manager defaults in
the DOS IDE
The Project Manager is especially useful when you're developing
Windows applications, since a Windows application often
consists of several modules of code, a module-definition file, and
a resource file. For complete details, see Chapter 8 in the
Programmer's Guide. The Project Manager's default behavior in the
Borland C++ IDEs is listed in the following tables.
File name
While compiling
x.RC
While linking
x.DEF
After linking
x.RES
Behavior
Transfers to the Resource Compiler to c<;>mpile x.RC
to x.RES
The IDE linker uses the information in x.DEF while
creating the .EXE
Transfers to the Resource Linker to bind x.RES to
the .EXE
Table 4.2 File name Behavior
Project Manager defaults in
the Windows IDE While compiling
x.RC
140
While linking
x.DEF
After linking
x.RES
Invokes the integrated Resource Compiler to
compile x.RC to x.RES
The IDE linker uses the information in x.DEF while
creating the .EXE
Invokes the integrated Resource Linker to bind
x.RES to the .EXE
Borland C++ User's Guide
Overriding libraries
In some cases, it's necessary to override the standard startup files
or libraries. You override the startup file by placing a file called
COx. OBI as the first name in your project file, where x stands for
any DOS name (for example, COMINE.OBJ). It's critical that the
name start with CO and that it is the first file in your project.
To override the standard library, choose Options I Linker and, in
the Libraries dialog box, select None for the Standard Run-time
Library. Then add the library you want your project to use to the
project file just as you would add any other item.
More Project Manager features
Let's take a look at some of the other features the Project Manager
has to offer. When you're working on a project that involves many
source files, you want to be able to easily view portions of those
files, and to record notes about what you're doing as you're
working. You'll also want to be able to quickly access files that are
included by others.
For example, expand MYMAIN.CPP to include a call to a function
named GetMyTime:
#include <iostream.h>
#inc1ude "myfuncs.h"
#inc1ude "mytime.h"
int main(int argc, char *argv[])
{
char *s;
if(argc > 1)
s=argv[l] ;
else
s="the universe";
cout GetString() s "\n";
return 0;
This code adds one new include file to MYMAIN: mytime.h.
Together myfuncs.h and mytime.h contain the prototypes that
define the GetString and GetMyTime functions, which are called
from MYMAIN. The mytime.h file contains
Chapter 4, Managing multi-file projects 141
142
#define HOUR 1
#define MINUTE 2
#define SECOND 3
extern int GetMyTime(int);
Now, put the code for GetMyTime into a new source file called
MYTIME.CPP:
#include <time.h>
#include "mytime.h"
int GetMyTime(int which)
{
struct tm *timeptr;
time_t secsnow;
time(&secsnow);
timeptr = localtime(&secsnow);
switch (which) {
case HOUR:
return (timeptr -> tm_hour);
case MINUTE:
return (timeptr -> tm_min);
case SECOND:
return (timeptr -> tm_sec);
MYTIME includes the standard header file time.h, which contains
the prototype of the time and localtime functions, and the
definition of tm and time_t, among other things. It also includes
mytime.h in order to define HOUR, MINUTE, and SECOND.
Create these new files, then use Project I Open Project to open
MYPROG.PRJ. The files MYMAIN.CPP and MYFUNCS.CPP are
still in the Project window. Now to build your expanded project,
add the file name MYTIME.CPP to the Project window. Press Ins,
choose Project I Add Item, or click Add Item on the SpeedBar to
open the Add Item dialog box. Use the dialog box to specify the
name of the file you are adding and choose Done.
Now choose Compile I Make to make the project. MYMAIN.CPP
will be recompiled because you've made changes to it since you
last compiled it. MYFUNCS.CPP won't be recompiled, because
you haven't made any changes to it since the make in the earlier
example. MYTIME.CPP will be compiled for the first time.
In the MYPROG project window, move to MYMAIN.CPP and
press Spacebar (or Project I Include Files) to display the Include
Files dialog box. You can also click View Includes on the
Borland C++ User's Guide
Looking at files in
a project
Notes for your
project
Borland C++ DOS IDE only
SpeedBar. This dialog box contains the name of the selected file,
several buttons, and a list of include files and locations (paths).
The first file in the Include Files list box is highlighted; the list box
lists all the files included by the file MYMAIN.CPP. If any of the
include files are located outside of the current directory, the path
to the file is shown in the Location field of the list box.
As each source file is compiled, the information about which
include files are included by which source files is stored in the
source file's .OBI file. If you access the Include Files dialog box
before you perform a make, it might contain no files or it might
have files left over from a previous compile (which may be out of
date). To load one of the include files into an edit window,
highlight the file you want and press Enter or click the View
button.
Let's take a look at MYMAIN.CPP, one of the files in the Project.
Choose the file using the arrow keys or the mouse, then press
Enter. This opens an edit window with MYMAIN.CPP loaded.
Now you can make changes to the file, scroll through it, search for
text, or whatever else you need to do. When you are finished with
the file, save your changes if any, then close the edit window.
Suppose that after browsing around in MYMAIN.CPP, you
, realize what you really wanted was to look at mytime.h, one of
the files that MYMAIN.CPP includes. Highlight MYMAIN.CPP in
the Project window, then press Spacebar to bring up the Include
Files dialog box for MYMAIN. (Alternatively, while
MYMAIN.CPP is the active edit window, choose Project I Include
Items.) Now choose mytime.h in the Include Files box and click
View. This brings up an edit window with mytime.h loaded.
When you're done, close the mytime.h edit window.
Now that you've had a chance to see the code in MYMAIN.CPP
and mytime.h, you might decide to make some changes at a later
time. Choose Window I Project Notes to bring up a new edit
window that is kept as part of your project file. Type in any
comments you want to remember about your project.
Each project maintains its own notes file, so that you can keep
notes about the project you're currently working on; they're
available at the touch of a button when you select the project file.
Chapter 4, Managing multi-file projects 143
144 Borland C++ User's Guide
c H
The command-line compiler
lets you invoke all the
functions of the IDE compiler
from the DOS command line.
A
p
T E R
5
The command-line compiler
As an alternative to using the IDE, you can compile and run your
programs with the command-line compiler (BCC.EXE). Almost
anything you can do within the IDE can also be done using the
command-line compiler. You can set warnings on or off, invoke
TASM (or another assembler) to assemble .ASM source files,
invoke the linker to generate executable files, and so on. In fact, if
you only want to compile your C or c++ source file(s), you must
use the -c option at the command line.
This chapter is organized into two parts. The first describes how
to use the command-line compiler and provides a summary table
of all the options. The second part, starting on page 152, presents
the options organized functionally (with groups of related
options).
The summary table, Table 5.1 (starting on page 147), summarizes
the command-line compiler options and provides a page-number
cross-reference to more detailed information about each option.
Using the command-line compiler
The command-line compiler uses DPMI to run in protected mode
on 80286, 80386, or i486 machines with 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
Chapter 5, The command-line compiler 145
DPMIINST
For more information about
running DPMIINST, see
Chapter 7, "Installing Borland
C++."
Running Bee
You can also use a configur-
ation file. See page 757 for
details.
Using the options
Compiler options are further
divided into 70 groups.
146
Borland C++ in protected mode is that the compiler has much
more room to run than in real mode, so it can compile larger
projects faster and without extensive disk-swapping.
The protected mode interface is completely transparent to the
user. Borland C++ uses an internal database of machine
characteristics to determine how to enable protected mode on
your machine, and configures itself accordingly. The only time
you may need to be aware of it is when running the compiler for
the first time. If your machine is not recognized by Borland C++,
you will need to run the DPMIINST program by typing (at the
DOS prompt)
DPMIINST
and following the program's instructions. DPMIINST runs your
machine through a series of tests to determine the best way of
enabling protected mode.
To invoke Borland C++ from the command line, type Bee at the
DOS prompt and follow it with a set of command-line arguments.
Command-line arguments include compiler and linker options
and file names. The generic command-line format is
BCC [option [option ... ]] filename [filename ... ]
Each command-line option may be preceded by either a hyphen
(-) or slash (I), whichever you prefer. Each option must be
separated from the BCC command, other options, and any
following file names by at least one space.
The options are divided into three types:
compiler options, described starting on page 152
linker options, described starting on page 171
environment options, described starting on page 172
To see an onscreen list of the options, type Bee (without any
options or file names) at the DOS prompt. Then press Enter.
Borland C++ User's Guide
Use this feature to override
settings in configuration files.
In order to select command-line options, enter a hyphen (-) or
slash (I) immediately followed by the option letter (for example,
-lor II). To turn an option off, add a second hyphen after the
option letter. This is true for all toggle options (those that turn an
option on or off): A trailing hyphen (-) turns the option off, and a
trailing plus sign (+) or nothing turns it on. So, for example, -C
and -C+ both turn nested comments on, while -C- turns nested
comments off.
Option-precedence
rules
The option-precedence rules are simple; command-line options
are evaluated from left to right, and the following rules apply:
iii For any option that is not an -lor -L option, a duplication on
the right overrides the same option on the left. (Thus an off
option on the right cancels an on option to the left.)
[J The -I and -L options on the left" however, take precedence
over those on the right.
Table 5.1: Command-line options summary
Option
@filename
+filename
-1
-1-
-2
-3
-A
-A-,-AT
-AK
-AU
-a
-a-
-B
-b
-b-
-C
-C-
-c
-Dname
-Dname=string
-d
-d-
-Efilename
-efilename
-Fc
-Ff
-Ff=size
Page
151
151
155
155
155
155
161
161
161
161
155
155
165
155
155
161
161
165
154
154
155
155
166
171
156
156
156
Function
Read compiler options from the response file filename
Use the alternate configuration file filename
Generate 80186 instructions
Generate 8088/8086 instructions (default)
Generate 80286 instructions
Generate 80386 instructions
Use only ANSI keywords (for C) and enforce strict rules (for C++)
Use Borland C++ keywords (default)
Use only Kernighan and Ritchie keywords
Use only UNIX keywords
Align word
Align byte (default)
Compile and call the assembler to process inline assembly code
Make enums always word-sized (default)
Make enums byte-sized when possible
Nested comments 'on
Nested comments off (default)
Compile to .OBJ but do not link
Define name to the null string
Define name to string
Merge duplicate strings on
Merge duplicate strings off (default)
Use filename as the assembler to use
Link to produce filename.EXE
Generate COMDEFs
Create far variables automatically
Create far variables automatically; sets the threshold to size
Chapter 5, The command-line compiler 147
Table 5.1: Command-line options summary (continued)
-Fm
-Fs
-f
-f-
-ff
-ff-
-f87
-f287
-G
-G-
-gn
-H
-H-
-Hu
-H=filename
-h
-Ipath
-in
-Jg
-Jgd
-Jgx
-jn
-K
-K-
-k
-Lpath
-Ix
-l-x
-M
-mc
-mh
-ml
-mm
-mm!
-ms
-ms!
-mt
-mt!
-N
-npath
-ofilename
-01
-02
-Od
-On
-ofilename
-P
-Pext
-P-
148
156
156
156
156
157
157
157
157
181
181
162
166
166
166
166
157
172
161
170
170
170
162
157
157
158
172
172
172
172
153
153
153
153
153
153
153
153
153
158
172
166
180
180
180
180
166
166
166
166
Enables the -Fc,-Ff, and -Fs options
Assume DS = SS in all memory models
Emulate floating-point (default)
Don't do floating-point
Fast floating-point (default)
Strict ANSI floating-point
Use 8087 hardware instructions
Use 80287/80387 hardware instructions
Select code for speed
Select code for size (default)
Warnings: stop after n messages
Causes the compiler to generate and use precompiled headers
Turns off generation and use of precompiled headers (default)
Tells the compiler to use but not generate precompiled headers
Sets the name of the file for precompiled headers
Use fast huge pointer arithmetic
Directories for include files
Make significant identifier length to be n
Generate definitions for all template instances and merge duplicates
(default)
Generate public definitions for all template instances; duplicates result in
redefinition errors
Generate external references for all template instances
Errors: stop after n messages
Default character type unsigned
Default character type signed (default)
Standard stack frame on (default)
Directories for libraries
Pass option x to the linker
Suppress option x for the linker
Instruct the linker to create a map file
Compile using compact memory model
Compile using huge memory model
Compile using large memory model
Compile using medium memory model
Compile using medium model; assume DS != SS
Compile using small memory model (default)
Compile using small model; assume DS != SS
Compile using tiny memory model
Compile using tiny model; assume DS != SS
Check for stack overflow
Set the output directory
Set the output .OBJ file name
Generate smallest possible code
Generate fastest possible code
Disable all optimizations
(Oa-Ox) Optimization options (see Appendix A for details)
Compile source file to filename.obj
Perform a C++ compile regardless of source file extension
Perform a C++ compile and set the default extension to ext
Perform a C++ or C compile depending on source file extension (default)
Borland C++ User's Guide
Table 5.1: Command-line options summary (continued)
-P-ext
-p
-po
-pr
-p-
-Qe
-Qe-
-Qx=nnnn
-r
-r-
-rd
-R
-S
-Tstring
-T-
-tDe
-tDc
-tW
-Uname
-u
-u-
-v,-v-
-vi,-vi-
-V
-Va
-Vb
-Vc
-Vf
-Vmv
-Vmm
-Vms
-Vmd
-Vmp
-Yo
-Vp
-Vs
-Vt
-Vv
-VO,-Vl
-W
-WD
-WDE
-WE
-WS
-w
166
158
158
158
158
168
168
168
180
180
180
81
167
167
167
171
172
172
154
158
158
159
160
168
173
173
173
169
170
170
170
170
170
174
173
169
173
174
169
167
167
167
167
167
162
Perform a C++ or C compile depending on extension; set default extension
to ext
Use Pascal calling convention
Use Object Data calling convention for passing this parameter in registers
Use fastcall calling convention for passing parameters in registers
Use C calling convention (default)
Instructs the compiler to use all available EMS memory (default)
Instructs the compiler to not use any EMS memory
Instructs the compiler to use I1nl1n Kbytes of extended memory
Use register variables on (default)
Suppresses the use of register variables
Only allow declared register variables to be kept in registers
Generate ObjectBrowser information
Produce .ASM output file
Pass string as an option to TASM or assembler specified with-E
Remove all previous assembler options
Make the target a DOS .EXE file
Make the target a DOS .COM file
Make the target a Windows module, using the same options as-W
Undefine any previous definitions of name
Genera te. underscores (defa ul t)
Disables underscores
Source debugging on
Controls expansion of inline functions
Smart C++ virtual tables
Pass class arguments by reference to a temporary variable
Make virtual base class pointer same size as this pointer of the class
Do not add the hidden members and code to classes with pointers to virtual
base class members
Far C++ virtual tables
Member pointers have no restrictions (most general representation)
Member pointers support multiple inheritance
Member pointers support single inheritance
Use the smallest representation for member pointers
Honor the declared precision for all member pointer types
Enable all the backward compatibility -V switches (-Va,-Vb,-Vc, -Vp,-Vt,
-Vv)
Pass the this parameter to pascal member functions as the first parameter on
the stack
Local C++ virtual tables
Place the virtual table pointer after nonstatic data members
Do not change the layout of classes to relax restrictions on member pointers
External and Public C++ virtual tables
Creates an .OBJ for Windows with all functions exportable
Creates an .OBJ for Windows to be linked as a .DLL with all functions
exportable
Creates an .OBJ for Windows to be linked as a .DLL with explicit export
functions
Creates an .OBJ for Windows with explicit export functions
Creates an .OBJ for Windows that uses smart callbacks
Display warnings on
Chapter 5, The command-line compiler 149
Table 5.1: Command-line options summary (continued)
-wxxx 162 Enable xxx warning message
-w-xxx 162 Disable xxx warning message
-X 159 Disable compiler autodependency output
-Y 159 Enable overlay code generation
-Yo 159 Overlay the compiled files
-y 159 Line numbers on
-Z 188 Enable register load suppression optimization
-zAname 164 Code class
-zBname 164 BSS class
-zCname 164 Code segment
-zDname 164 BSS segment
-zEname 164 Far segment
-zFname 164 Far class
-zGname 165 BSS group
-zHname 165 Far group
-zPname 165 Code group
-zRname 165 Data segment
-zSname 165 Data group
-zTname 165 Data class
-zVname 165 Far virtual table segment
-zWname 165 Far virtual table class
-zx* 165 Use default name for X. (default)
Syntax and file
names Borland C++ compiles files according to the following set of rules:
c++ files have the extension
. CPP; see page 766 for
information on changing the
default extension.
150
FILENAME.ASM Invoke TASM to assemble to .OBI
FILENAME. OBI Include as object at link time
FILENAME. LIB Include as library at link time
FILENAME Compile FILENAME.CPP
FILENAME.CPP Compile FILENAME.CPP
FILENAME.C Compile FILENAME.C
FILENAME.XYZ Compile FILENAME.XYZ
For example, given the following command line
BCC -a -f -C -01 -emyexe oldfile1 oldfile2 nextfile
Borland C++ compiles OLDFILEl.CPP, OLDFILE2.CPP, and
NEXTFILE.CPP to an .OBI, linking them to produce an executable
program file named MYEXE.EXE with word alignment (-a),
floating-point emulation (-f), nested comments (-C), and generate
smallest code (-01) selected.
Borland C++ invokes TASM if you give it an .ASM file on the
command line or if a.C or .CPP file contains inline assembly.
Borland C++ User's Guide
Response files'
Response files allow you to
have longer command
strings than DOS normally
allows.
See page 147 for rules about
response-file options.
Configuration files
TURBOC.CFG is not the same
as TCCONFIG. TC, which is
the default IDE version of a
configuration file.
Here are the options that the command-line compiler gives to
TASM:
ID __ MODEL _ _ ID __ LANG _ _ Iml IFLOATOPT
where MODEL is one of: TINY, SMALL, MEDIUM, COMPACT,
LARGE, or HUGE. The Iml option tells TASM to assemble with
case sensitivity on. LANG is CDECL or PASCAL; FLOATOPT is r
when you've specified -187 or -1287; e otherwise.
If you need to specify many options or files on the command line,
you can place them in an ASCII text file, called a response file (you
can of course name it anything you like). You can then tell the
command-line compiler to read its command line from this file by
including the appropriate file name prefixed with @. You can
specify any nU1l1bef of such files, and mi;.: them freely vlith other
options and file names.
For example, suppose the file MOON.RSP contains ST ARS.C and
RAIN.C. This command
BCC SUN.C @MOON.RSP ANYONE.C
causes Borland C++ to compile the files SUN.C, STARS.C,
RAIN.C, and ANYONE.C in real mode. It expands to
BCC SUN.C STARS.C RAIN.C ANYONE.C
Any options included in a response file are evaluated just as
though they had been typed in on the command line.
If you use a set of options repeatedly, you can list them in a con-
figuration file, called TURBOC.CFG by default. If you have a
TURBOC.CFG configuration file, you don't need to worry about
using it. When you run BCC, it automatically looks for
TURBOC.CFG in the current directory. If it doesn't find it there,
Borland C++ then looks in the startup directory (where BCC.EXE
resides).
You can create more than one configuration file; each must have a
unique name. To specify the alternate configuration-file name, in-
clude its file name, prefixed with +, anywhere on the BCC
command line. For example, to read the option settings from the
file D:\ALT.CFG, you could use the following command line:
Chapter 5, The command-line compiler 151
Option-precedence
rules
Bee +D:\ALT.CFG ..... .
Your configuration file can be used in addition to or instead of
options entered on the command line. If you don't want to use
certain options listed in your configuration file, you can override
them with options on the command line.
You can create the TURBOC.CFG file (or any alternate configura-
tion file) using any standard ASCII editor or word processor, such
as Borland C++'s integrated editor. You can list options (separated
by spaces) on the same line or list them on separate lines.
In general, remember that command-line options override config-
uration-file options. If, for example, your configuration file
contains several options, including the -a option (which you want
to tunl off), you can still use the configuration file but override the
-a option by listing -a- in the command line. However, the rules
are a little more detailed than that. The option precedence rules
detailed on page 147 apply, with these additional rules:
1. When the options from the configuration file are combined
with the command-line options, any -I and -L options in the
configuration file are appended to the right of the command-
line options. This means that the include and library direc-
tories specified in the command line are the first ones Borland
C++ searches (thereby giving the command-line -I and-L
directories priority over those in the configuration file).
2. The remaining configuration file options are inserted imme-
diately after the BCC command (to the left of any command-
line options). This gives the command-line options priority
over the configuration file options.
Compiler options
Borland C++'s command-line compiler options fall into 10 groups;
the page references to the left of each group tell where you can
find a discussion of each kind of option:
See page 753. 1. Memory model options let you tell Borland C++ which memory
model to use when compiling your program.
See page 754. 2. Macro definitions let you define and undefine macros on the
command line.
152 Borland C++ User's Guide
See page 755. 3. Code-generation options govern characteristics of the generated
code, such as the floating-point option, calling convention,
character type, or CPU instructions.
See Appendix A. 4. Optimization options let you specify how the object code is to be
optimized; a more detailed discussion of optimization options
appears in Appendix A, "The Optimizer."
See page 760. 5. Source-code options cause the compiler to recognize (or ignore)
certain features of the source code; implementation-specific
(non-ANSI, non-Kernighan and Ritchie, and non-UNIX) key-
words, nested comments, and identifier lengths.
See page 762. 6. Error-reporting options let you tailor which warning messages
the compiler reports, and the maximum number of warnings
and errors that can occur before the compilation stops.
See page 764. 7. Segment-naming control options allow you to rename segments
and reassign their groups and classes.
See page 165. 8. Compilation-control options let you direct the compiler to
[] compile to assembly code (rather than to an object module)
c compile a source file that contains inline assembly
II compile without linking
c compile for Windows applications
m use precompiled headers or not
See page 768. 9. EMS options let you control how much expanded or extended
memory Borland C++ uses.
See page 768. 10. C++ virtual-table options let you control how virtual tables are
handled.
See page 769. 11. C++ member-pointer options let you control how member
pointers are used.
See page 770. 12. Template-generation options let you control how the compiler
generates definitions or external declarations for template
instances.
See page 773. 13. Backward-compatibility options let you tell the compiler to use
particular code-generation strategies to insure backward
compatibility with earlier versions of Borland C++.
Memory model
Memory-model options let you tell Borland C++ which memory
model to use when compiling your program. The memory models
are tiny, small, medium, compact, large, and huge.
Chapter 5, The command-line compiler 153
See Chapter 9 in the
Programmer's Guide for in-
depth information on the
memory models (what they
are, how to use them).
You can't use the -N option
when using one of the OS /=
SSmodels.
Macro definitions
154
-me Compile using compact memory model
-mh Compile using huge memory model
-ml Compile using large memory model
-mm Compile using medium memory model
-mm! Compile using medium model; DS!= SS
-ms Compile using small memory model (the default)
-ms! Compile using small model; DS != SS
-mt Compile using tiny memory model
-mt! Compile using tiny model; DS != SS
The net effect of the -mt!, -ms!, and -mm! options is actually very
small. If you take the address of a stack variable (auto or param-
eter), the default (when DS == SS) is to make the resulting pointer
a near (DS relative) pointer. In this way you can assign the
address to a default-sized pointer in those models without
problems.
When DS!= SS, the pointer type created when you take the
address of a stack variable is an _ss pointer. This means that the
pointer can be freely assigned or passed to a far pointer or to a
_ss pointer. But for the memory models affected, assigning the
address to a near or default-sized pointer will produce a "Suspi-
cious pointer conversion" warning. Such warnings are usually
errors, and the warning defaults to On. You should regard this
kind of warning as a likely error.
Macro definitions let you define and undefine macros (also called
manifest or symbolic constants) on the command line. The default
definition is the null string.
-Dname Defines the named identifier name to the null
string.
-D name= string Defines the named identifier name to the string
string after the equal sign. string cannot contain
any spaces or tabs.
-Uname Undefines any previous definitions of the
named identifier name.
Borland C++ lets you make multiple #define entries on the
command line in any of the following ways:
Borland C++ User's Guide
Code-generation
options
r:J You can include multiple entries after a single -0 option, sepa-
rating entries with a semicolon (this is known as "ganging"
options):
BCC -Dxxx;yyy=l;zzz=NO MYFILE.C
r:J You can place more than one -0 option on the command line:
BCC -Dxxx -Dyyy=l -Dzzz=NO MYFILE.C
r:J You can mix ganged and multiple -0 listings:
BCC -Dxxx -Dyyy=l;zzz=NO MYFILE.C
Code-generation options govern characteristics of the generated
code, such as the floating-point option, calling convention, charac-
ter type, or CPU instructions.
-1 This option causes Borland C++ to generate extended
80186 instructions. It also generates 80286 programs
running in real mode, such as with the IBM PCI AT
under DOS.
-1- This option tells the compiler to generate 8088/8086
instructions (the default).
-2 This option causes Borland C++ to generate 80286
instructions.
-3 This option causes Borland C++ to generate 80386
instructions.
-a This option forces integer size and larger items to be
aligned on a machine-word boundary. Extra bytes are
inserted in a structure to ensure member alignment.
Automatic and global variables are aligned properly.
char and unsigned char variables and fields can be
placed at any address; all others are placed at an even-
numbered address. This option is off by default (-a-),
allowing bytewise alignment.
-b This option (the default) tells the compiler to always
allocate a whole word for enumeration types.
-b- This option tells the compiler to allocate a signed or
unsigned byte if the minimum and maximum values of
the enumeration are both within the range of 0 to 255 or
-128 to 127, respectively.
Chapter 5, The command-line compiler 155
156
-d This option tells the compiler to merge literal strings
when one string matches another, thereby producing
smaller programs. This option is off by default (-d-).
-Fc This generates communal variables (COMDEFs) for
global"C" variables that are not initialized and not
declared as static or extern. The advantage of using this
option is that header files included in several source files
can contain declarations of global variables. 50 long as a
given variable doesn't need to be initialized to a nonzero
value, you don't need to include a definition for it in any
of the source files. You can use this option when porting
code that takes advantage of a similar feature with
another implementation.
-Ff When you use this option, global variables greater than
or equal to the threshold size are automatically made far
by the compiler. The threshold size defaults to 32,767;
you can change it with the -Ff=size option. This option
is useful for code that doesn't use the huge memory
model but declares enough large global variables that
their total size exceeds (or is close to) 64K. For tiny,
small, and medium models this option has no effect.
If you use this option in conjunction with -Fc, the
generated COMDEFs will be far in the compact, large,
and huge models.
-Ff=size Use this option to change the threshold size used by the
-Fm
-Fs
-f
-Ff option.
This option enables all the other -F options (-Fc, -Ff and
-Fs). You can use it as a handy shortcut when porting
code from other compilers.
This option tells the compiler to assume that D5 is equal
to 55 in all memory models; you can use it when porting
code originally written for an implementation that
makes the stack part of the data segment. When you
specify this option, the compiler links in an alternate
startup module (COFx.OBJ) that places the stack in the
data segment.
This option tells the compiler to emulate 80x87 calls at
run time if the run-time system does not have an 80x87;
if it does have one, the compiler calls the 80x87 chip for
floating-point calculations (the default).
Borland C++ User's Guide
-f- This option specifies that the program contains no
floating-point calculations. No floating-point libraries
will be linked at the link step.
-ff With this option, the compiler optimizes floating-point
operations without regard to explicit or implicit type
conversions. Answers can be faster than under ANSI
operating mode. See Chapter 10, "Math," in the
Programmer's Guide for details.
-ff- This option turns off the fast floating-point option. The
compiler follows strict ANSI rules regarding floating-
point conversions.
-f87 This option tells the compiler to generate floating-point
operations using inline 80x87 instructions rather than by
using calls to 80x87 emulation library routines. It spec-
ifies that a math coprocessor will be available at run
time; therefore, programs compiled with this option will
not run on a machine without a math coprocessor.
The 80287 and 80387 have -f287
This option is similar to -f87, but uses instructions that
are available only with an 80287, 80387, or higher chip.
the same instruction set.
-h This option offers an alternative way of calculating huge
pointer expressions; a way which is much faster but
must be used with caution. When you use this option,
huge pointers are normalized only when a segment
wraparound occurs in the offset part. This causes
problems for huge arrays if any array elements cross a
segment boundary. This option is off by default.
Borland C++ normalizes a huge pointer whenever
adding to or subtracting from it. This ensures that, for
example, if you have a huge array of structs that's larger
than 64K, indexing into the array and selecting a struct
field will always work with structs of any size. Borland
C++ accomplishes this by always normalizing the
results of huge pointer operations, so that the offset part
contains a number that's no higher than 15. That way, a
segment wraparound never occurs with huge pointers.
The disadvantage of this approach is that it tends to be
quite expensive in terms of execution speed. This option
is automatically selected when compiling for Windows.
-K This option tells the compiler to treat all char declar-
ations as if they were unsigned char type. This allows
Chapter 5, The command-line compiler 157
-k
-N
-p
-po
-pr
-u
158
for compatibility with other compilers that treat char
declarations as unsigned. By default, char declarations
are signed (-K-).
This option generates a standard stack frame, which is
useful when using a debugger to trace back through the
stack of called subroutines. This option is on by default.
This option generates stack-overflow logic at the entry of
each function, which causes a stack-overflow message to
appear when a stack overflow is detected. This is costly
in terms of both program size and speed but is provided
as an option because stack overflows can be very diffi-
cult to detect. If an overflow is detected, the message
"Stack overflow!" is printed and the program exits with
an exit code of 1.
This option forces the compiler to generate all
subroutine calls and all functions using the Pascal
parameter-passing sequence. The resulting function calls
are smaller and faster. Functions must pass the correct
number and type of arguments, unlike normal C use,
which permits a variable number of function arguments.
You can use the cdecl statement to override this option
and specifically declare functions to be C-type. This
option is off by default (-p-).
This option forces the compiler to generate all calls to
member functions using the Object Data calling
convention. With Object Data enabled, member
functions expect their hidden this parameter to be
supplied in registers. You can control Object Data's use
on a class-by-class basis using #pragma option -po. For
more information about Object Data, see Appendix A.
This option forces the compiler to generate all
subroutine calls and all functions using the new fastcall
parameter-passing convention. With this option
enabled, functions expect parameters to be passed in
registers. You can also individually override the cdecl or
pascal calling conventions by using the _fastcall
modifier in declaring a function. For more information
about _fastcall, see Appendix A.
With -u selected, when you declare an identifier,
Borland C++ automatically puts an underscore (_) in
Borland C++ User's Guide
Unless you are an expert,
don't use -u-. See Chapter
72, "BASM and inline
assembly," in the
Programmer's Guide for
details about underscores.
-x
front of the identifier before saving the identifier in the
object module.
Borland C++ treats Pascal-type identifiers (those
modified by the pascal keyword) differently-they are
uppercase and are not prefixed with an underscore.
Underscores for C and C++ identifiers are optional, but
on by default. You can turn them off with -U-. However,
if you are using the standard Borland C++ libraries, you
will encounter problems unless you rebuild the libraries.
(To do this, you will need the Borland C++ run-time
library source code; contact Borland for more
informa tion.)
This option disables generation of auto dependency in-
formation in the output file. Modules compiled with this
option enabled will not be able to use the autodepen-
dency feature of MAKE or of the IDE. Normally this
option is only used for files that are to be put into .LIB
files (to save disk space).
You can't use this option if -V
you're using any of the-W
(Windows applications)
options (and vice versa).
This option generates overlay-compatible code. Every
file in an overlaid program must be compiled with this
option; see Chapter 9, "DOS memory management," in
the Programmer's Guide for details on overlays.
-Vo This option overlays the compiled file(s); see Chapter 9
in the Programmer's Guide for details.
-y This option includes line numbers in the object file for
use by a symbolic debugger, such as Turbo Debugger.
This increases the size of the object file but doesn't affect.
size or speed of the executable program. This option is
useful only in concert with a symbolic debugger that can
use the information. In general, -v is more useful than
-y with Turbo Debugger.
The -v and -vi options -v This option tells the compiler to include debugging in-
formation in the .OB} file so the file(s) being compiled
can be debugged with either Borland C++'s integrated
debugger or the standalone Turbo Debugger. The com-
piler also passes this option on to the linker so it can
include the debugging information in the .EXE file.
Turbo Debugger is both a
source-level (symbolic) and
assembly level debugger.
Chapter 5, The command-line compiler 159
Optimization
options
Source-code
To facilitate debugging, this option also causes C++ in-
line functions to be treated as normal functions. If you
want to avoid that, use -vi.
-vi With this option enabled, C++ inline functions are ex-
panded inline.
To control the expansion of inline functions, the operation of the
-v option is slightly different in C++. When inline function
expansion is not enabled, the function will be generated and
called like any other function. Debugging in the presence of inline
expansion can be extremely difficult, so we provide the following
options:
-v turns debugging on and inline expansion off
-v- turns debugging off and inline expansion on
-vi turns inline expansion on
-vi- turns inline expansion off
So, for example, if you want to turn both debugging and inline
expansion on, use -v -vi.
Borland C++ is a professional optimizing compiler, featuring a
number of options that let you specify how the object code is to be
optimized; for size or speed, and utilizing (or not) a wide range of
optimization techniques. Appendix A, "The Optimizer," discusses
these options in detail.
options Source-code options cause the compiler to recognize (or ignore)
certain features of the source code; implementation-specific (non-
ANSI, non-Kernighan and Ritchie, and non-UNIX) keywords,
nested comments, and identifier lengths. These options are most
significant if you plan to port your code to other systems.
-A This option is used to enforce ANSI compatible code
when compiling C code: Any of the Borland C++
extension keywords are ignored and can be used as
normal identifiers. These keywords include
160 Borland C++ User's Guide
See Chapter 1 in the
Programmer's Guide for a
complete list of the Borland
C++ keywords.
-A-
-AI<
-AU
-c
-in
asm
-
es interrupt
-
ss
cdecl _export loadds _saveregs
cs far near _fastcall
-
-
ds huge pascal _seg
and the register pseudovariables, such as _AX, _BX, _51,
and so on.
When compiling C++ code, this option enforces certain
rules found in Ellis and Stroustrup's The Annotated c++
Reference Manual (Addison-Wesley, 1990, ISBN
0-201-51459-1) and the ANSI C++ working document.
These rules can changes some warnings to errors. Since
they cause a lot of existing code to not compile, the rules
aren't enforced by default.
This option tells the compiler to use Borland C++
keJn;-!ords. -.A.T is an alternate version of this option.
This option tells the compiler to use only Kernighan and
Ritchie keywords.
This option tells the compiler to use only UNIX key-
words.
This option allows you to nest comments. Comments may
not normally be nested.
This option causes the compiler to recognize only the first
n characters of identifiers in C source code. (The option is
ignored when compiling C++.) All identifiers, whether
variables, preprocessor macro names, or structure mem-
ber names, are treated as distinct only if their first n char-
acters are distinct.
By default, Borland C++ uses 32 characters per identifier.
Other systems, including some UNIX compilers, ignore
characters beyond the first eight. If you are porting to
these other environments, you may wish to compile your
code with a smaller number of significant characters.
Compiling in this manner will help you see if there are
any name conflicts in long identifiers when they are
truncated to a shorter significant length.
Chapter 5, The command-line compiler 161
Error-reporting
options
For more information on
these warnings, see
Appendix A "Error mes-
sages," in the Tools and
Utilities Guide.
An asterisk (*) after the
option in the following
sections indicates that the
option is on by default. All
others are off by default.
ANSI violations
162
Error-reporting options let you tailor which warning messages
the compiler reports, and the maximum number of warnings and
errors that can occur before the compilation stops.
-gn This option tells Borland C++ to stop compiling after n
warning messages.
-jn This option tells the compiler to stop compiling after n
error messages.
-w This option causes the compiler to display warning
messages. You can turn this off with -w-. You can
enable or disable specific warning messages with
-wxxx, described in the following paragraphs.
-wxxx
-wbbf
-wbig*
-wdpu*
-wdup*
-weas
-wext*
-wpin
-wret*
-wstu*
-wsus*
-wvoi*
-wzdi*
This option enables the specific warning message
indicated by xxx. The option -w-xxx suppresses the
warning message indicated by xxx. The possible
options for -wxxx are listed here and divided into four
categories: ANSI violations, frequent errors (including
more-frequent errors), portability warnings, and C++
warnings. You can also use the pragma warn in your
source code to control these options. See Chapter 4,
"The preprocessor," in the Programmer's Guide.
Bit fields must be signed or unsigned into
Hexadecimal value contains more than three digits.
Declare type prior to use in prototype.
Redefinition of macro is not identical.
Assigning type to enumeration.
Identifier is declared as both external and static.
Initialization is only partially bracketed.
Both return and return with a value used.
Undefined structure structure.
Suspicious pointer conversion.
Void functions may not return a value.
Division by zero.
Borland C++ User's Guide
Frequent errors -wamb
-wamp
-wasm
-waus*
-wccc*
-wdef
-weff*
-wias*
-will *
-wnod
-wpar*
-wpia*
-wpro*
-wrch*
-wrvl*
-wstv
Portability warnings -wcln
-wcpt*
-wrng*
-wrpt*
-wsig
-wucp
c++ warnings -wbei*
-wdsz*
-whid*
-wibc*
-winl*
-wlin*
-wlvc*
-wmpc*
-wmpd*
-wncf*
-wnci*
-wnst*
-wnvf*
Chapter 5, The command-line compiler
Ambiguous operators need parentheses.
Superfluous & with function or array.
Unknown assembler instruction.
Identifier is assigned a value that is never used.
Condition is always true/ false.
Possible use of identifier before definition.
Code has no effect.
Array variable identifier is near.
Ill-formed pragma.
No declaration for function function.
Parameter parameter is never used.
Possibly incorrect assignment.
Call to function with no prototype.
Unreachable code.
Function should return a value.
Structure passed by value.
.. J.;C;" .. h l- ....
.LUI..-, H 'j tl..-' .10:> cu. LJ U.L .1 LC V C.1 u.o:>cu..
Constant is long.
Nonportable pointer comparison.
Constant out of range in comparison.
Nonportable pointer conversion.
Conversion may lose significant digits.
Mixing pointers to signed and unsigned char.
Initializing enumeration with type.
Array size for 'delete' ignored.
Functionl hides virtual function function2.
Base class basel is inaccessible because also in base2.
Functions containing identifier are not expanded inline.
Temporary used to initialize identifier.
Temporary used for parameter in call to identifier.
Conversion to type will fail for members of virtual base
class base.
Maximum precision used for member pointer type
type.
Non-const function function called const object.
Constant member identifier is not initialized.
Use qualified name to access nested type type.
Non-volatile function function called for volatile object.
163
Segment-naming
control
Don't use these options
unless you have a good
understanding of segmen-
tation on the 8086 processor.
Under normal circumstances,
you will not need to specify
segment names.
-wobi*
-wofp*
-wovl*
-wpre
Base initialization without a class name is now
obsolete.
Style of function definition is now obsolete.
Overload is now unnecessary and obsolete.
Overloaded prefix operator ++ / - used as a postfix
operator.
Segment-naming control options allow you to rename segments
and reassign their groups and classes.
-zAname This option changes the name of the code segment
class to name. By default, the code segment is
assigned to class CODE.
-zBname
-zCname
-zDname
This option changes the name of the uninitialized
data segment class to name. By default, the
uninitialized data segments are assigned to class
BSS.
This option changes the name of the code segment
to name. By default, the code segment is named
_TEXT, except for the medium, large and huge
models, where the name is filename_TEXT. (filename
here is the source file name.)
This option changes the name of the uninitialized
data segment to name. By default, the uninitialized
data segment is named _BSS, except in the huge
model, where no uninitialized data segment is
generated.
See Chapter 9, "DOS mem- -zEname
ory management, " in the
Programmer's Guide for
This option changes the name of the segment where
far objects are put to name. By default, the segment
name is the name of the far object followed by
_FAR. A name beginning with an asterisk (*) indi-
cates that the default string should be used.
more on far objects.
-zFname
-zGname
164
This option changes the name of the class for far
objects to name. By default, the name is FAR_DATA.
A name beginning with an asterisk (*) indicates that
the default string should be used.
This option changes the name of the uninitialized
data segment group to name. By default, the data
Borland C++ User's Guide
Compilation-
control options
-zHname
-zPname
-zRname
-zSname
group is named DGROUP, except in the huge
model, where there is no data group.
This option causes far objects to be put into group
name. By default, far objects are not put into a group.
A name beginning with an asterisk (*) indicates that
the default string should be used.
This option causes any output files to be generated
with a code group for the code segment named
name.
This option sets the name of the initialized data
segment to name. By default, the initialized data
segment is named _DATA, except in the huge
model, where the segment is named filename_DATA.
This option changes the name of the initialized data
segnlenl group to name. By default, the data group is
named DGROUP, except in the huge model, where
there is no data group.
-zTname This option sets the name of the initialized data
segment class to name. By default the initialized data
segment class is named DATA.
-zV name This option sets the name of the far virtual table
segment to name. By default far virtual tables are
generated in the code segment.
-zW name This option sets the name of the far virtual table
class segment to name. By default far virtual table
classes are generated in the CODE segment.
-zX* This option uses the default name for X. For
example, -zA * assigns the default class name CODE
to the code segment.
Compilation-control options allow you to control the compilation
of source files, such as whether your code is compiled as C or
C++, whether to use precompiled headers, and what kind of Win-
dows executable file is created. For more detailed information on
how to create an Windows application, see Chapter 8, "Building a
Windows application" in the Programmer's Guide.
Chapter 5, The command-line compiler 165
-8
-c
-Efilename
This option compiles and calls the assembler to
process inline assembly code.
This option compiles and assembles the named
.C, .CPP, and .ASM files, but does not execute a
link command.
This option uses name as the name of the
assembler to use. By default, TASM is used.
See Appendix 0 for more on -H
precompiled headers.
This option causes the compiler to generate and
use precompiled headers, using the default
filename TCDEF.SYM.
-H- This option turns off generation and use of pre-
compiled headers (this is the default).
-Hu This option tells the compiler to use but not gen-
erate precompiled headers.
-H=filename This option sets the name of the file for precom-
piled headers, if you wish to save this
information in a file other than TCDEF.5YM. This
option also turns on generation and use of pre-
compiled headers; that is, it also has the effect of
-H.
-0 filename This option compiles the named file to the
specified filename.OBJ.
This option behaves -p
differently from the -P option
This option causes the compiler to compile your
code as C++ always, regardless of extension. The
compiler assumes that all files have .CPP
extensions unless a different extension is
specified with the code.
in Turbo C++ 7.x.
-Pext'
-P-
166
This option causes the compiler to compile all
files as C++; it changes the default extension to
whatever you specify with ext. This option is
available because some programmers use .C or
another extension as their default extension for
C++ code.
This option tells the compiler to compile a file as
either C or C++, based on its extension. The
default extension is .CPP. This option is the
default.
Borland C++ User's Guide
-P-ext
-s
-Tstring
-T-
These five options (-W, -WD, -W
-WDE, -WE, and -WS) relate
to creating Windows appli-
cations. You can't use any of
these options if you're using
the - Y option (and vice
versa).
-WO
-WOE
-WE
-ws
Chapter 5, The command-line compiler
This option also tells the compiler to compile
code based on the extension (.CPP as C++ code,
all'other file-name extensions as C code). It
further specifies what the default extension is to
be.
This option compiles the named source files and
produces assembly language output files (.ASM),
but does not assemble. When you use this option,
Borland C++ includes the C or C++ source lines
as comments in the produced .ASM file.
This option passes string as an option to T ASM
(or as an option to the assembler defined with
-E).
This option removes all previously defined
assembler options.
This option creates the most general kind of Win-
dows executable, although not necessarily the
most efficient. The compiler makes every far
function exportable. This does not mean that all
far functions will be exported; it only means that
each far function can be exported. In order to
export one of these functions, you must either use
the _export keyword or add an entry for the
function name in the EXPORTS section of the
module-definition file.
This option creates a module for use in a .DLL
with all functions exportable.
This option creates a module for use in a .DLL
with only those functions explicitly designated
with _export as exportable.
This option creates an object module with only
those functions explicitly designated with _export
as exportable. .
This option creates an .OBJ with functions using
smart callbacks. This option is recommended if
you are writing Windows applications (not DLLs)
which can assume SS = DS (most can). This
option simplifies Windows programming; for
instance, using it, you no longer need
MakeProclnstance or FreeProclnstance, nor do
167
Expanded and
extended
memory options
you need to export your window procedures or
callback functions; instead, you can directly call
them. Enabling this option results in faster Win-
dows executables.
If you have expanded (EMS) memory, you may want to make this
memory available to the compiler for "swap" space in the event
that your computer's extended (protected mode) memory is
exhausted during compilation. These options give you the ability
to control the compiler's use of EMS memory. You can also control
the amount of extended (protected mode) memory Borland C++
uses.
~ The memory options can't appear in your TURBOC.CFG file.
c++ virtual tables
168
-Qe This option instructs the compiler to use all EMS
memory it can find. This is on by default for the
command-line compiler (BCC). It speeds up your
compilations, especially for large source files.
-Qe=yyyy This option instructs the compiler to use yyyy
pages (in 16K page sizes) of EMS memory for
itself.
-Qe-
-Qx=nnnn
This option instructs the compiler not to use any
EMS memory.
This option instructs the compiler to use nnnnK of
extended memory.
The -v option controls the C++ virtual tables. There are five varia-
tions of the -v option:
-v
-vs
Use this option when you want to generate C++ virtual
tables (and inline functions not expanded inline) so
that only one instance of a given virtual table or inline
function is included in the program. This produces the
smallest executables, but uses .OB] and .ASM exten-
sions only available with TLINK 3.0 and T ASM 2.0 (or
newer).
Use this option to generate local virtual tables (and
inline functions not expanded inline) such that each
Borland C++ User's Guide
c++ member
module gets its own private copy of each virtual table
(or inline function) it uses. This option uses only
standard .OB} (and .ASM) constructs, but produces
larger executables.
-VO, -V1 These options work together to create global virtual
tables. If you don't want to use the Smart or Local
options (-V or -Vs), you can use -VO and -V1 to
produce and reference global virtual tables. -VO
generates external references to virtual tables; -V1
produces public definitions for virtual tables.
When using these two options, at least one of the
modules in the program must be compiled with the
-V1 option to supply the definitions for the virtual
tables. All other modules should be compiled with the
-VO option to refer to that public copy of the virtual
tables.
-Vf You can use this option independently of or in
conjunction with any of the other virtual table options.
It causes virtual tables to be created in the code
segment instead of the data segment (unless changed
using the -zV and -zW options), and makes virtual
table pointers into full 32-bit pointers (the latter is done
automatically if you are using the huge memory
model).
There are two primary reasons for using this option: to
remove the virtual tables from the data segment, which
may be getting full, and to be able to share objects (of
classes with virtual functions) between modules that
use different data segments (for example, a DLL and an
executable using that DLL). You must compile all
modules that may share objects either entirely with or
entirely without this option. You can achieve the same
effect by using the huge or _export modifiers on a
class-by-class basis.
pointers The -Vm options control C++ member-pointer types. There are
five variations of the -Vm option:
The Borland C++ compiler supports three different kinds of
member-pointer types, with varying degrees of complexity and
Chapter 5, The command-line compiler 169
170
generality. By default, the compiler will use the most general (but
in some contexts also the least efficient) kind for all member-
pointer types; this default behavior can be changed via the -Vm
family of switches.
-Vmv
-Vmm
-Vms
-Vmd
-Vmp
Member pointers declared while this option is in effect
have no restriction on which members they can point
to; they use the most general representation.
Member pointers declared while this option is in effect
are allowed to point to members of multiple inheri-
tance classes, except that members of virtual base
classes cannot be pointed to.
Member pointers declared while this option is in effect
are not allowed to point to members of some base
classes of classes that use multiple inheritance (in
general, they can be used with single inheritance
classes only).
Member pointers declared while this option is in effect
use the smallest possible representation that allows
member pointers to point to all members of their class.
If the class is not fully defined at the point where the
member pointer type is declared, the most general
representation has to be chosen by the compiler (and a
warning is issued about this).
Whenever a member pointer is dereferenced or called,
the compiler treats the member pointer as if it were of
the least general case needed for that particular pointer
type. For example, a call through a pointer to member
of a class declared without any base classes treats the
member pointer as having the simplest representation,
regardless of how it's been declared.
This will work correctly (and produce the most
efficient code) in all cases except for one: when a
pointer to a derived class is explicitly cast to a pointer
to a member of a "simpler" base class, when the
pointer is actually pointing to a derived class member.
This is a nonportable (and dubious) construct, but if
you need to compile code that uses it, use the -Vmp
option, which forces the compiler to honor the declared
precision for all member-pointer types.
Borland C++ User's Guide
Template-
generation
options
The -Jg option controls the generation of template instances in
C++. There are three variations of the -Jg option:
-Jg Public definitions of all template instances encountered
when this switch value is in effect are generated. If
more than one module generates the same template
instance, the linker merges them to produce a single
copy of the instance. This option (the default) is the
most convenient approach to generating template
instances.
In order to generate the instances, however, the
compiler must have available the function body (in the
case of a template function) or the bodies of member
functions and definitions for static data members (in
the case of a template class).
-Jgd This option tells the compiler to generate public
definitions for all template instances encountered.
Unlike the -Jg option, however, duplicate instances are
not merged, causing the linker to report public symbol
redefinition errors if more than one module defines the
same template instance.
For more information about -Jgx
templates, see Chapter 3,
This option instructs the compiler to generate external
references to template instances. If you use this option,
make sure the instances are publicly defined in some
other module (using the -Jgd option), so that the
external references will be satisfied.
"C++ specifics," in the
Programmers Guide.
Linker options
See the section on TLINK in -efilename
the Tools and Utilities Guide
for a list of linker options.
Chapter 5, The command-line compiler
This option derives the executable program's name
from filename by adding the file extension .EXE (the
program name is filename.EXE). filename must
immediately follow the -e, with no intervening
whitespace. Without this option, the linker derives
the .EXE file's name from the name of the first
source or object file in the file name list. The
default extension is .DLL when you are using -WO
or-WOE.
171
-tOe
-tOe
-tW[nn]
-Ix
-M
This option specifies that the target (output) file is
a DOS .EXE file.
This option specifies that the target (output) file is
a DOS .COM file.
This specifies that the target (output) file is a
Windows module. It is identical to the -W
option(s) described on 167: -W, -WO, -WOE, -WE,
-WS, where the optional nn may be equal to 0, DE,
E orS.
This option (which is a lowercase 1) passes option x
to the linker. The option -I-x suppresses option x.
This option forces the linker to produce a full link
map. The default is to produce no link map.
Environment options
172
When working with environment options, bear in mind that
Borland C++ recognizes two types of library files: implicit and
user-specified (also known as explicit library files). These are
defined and discussed on page 175.
-Ipath
-Lpath
-npath
This option (which is an uppercase I) causes the
compiler to search path (the drive specifier or path
name of a subdirectory) for include files (in
addition to the standard places). A
drive specifier is a single letter, either uppercase
or lowercase, followed by a colon (:). A directory
is any valid directory or directory path. You can
use more than one -I directory option.
This option forces the linker to get the COx.OBJ
start-up object file and the Borland C++ library
files (Cx.LIB, MATHx.LIB, EMU.LIB, and so on)
from the named directory. By default, the linker
looks for them in the current directory.
This option places any .OBJ or .ASM files created
by the compiler in the directory or drive named
by path.
Borland C++ User's Guide
Backward-compatibility options
In this section, "previous"
versions are those before
Borland C++ version 3.0.
Borland C++ introduces a number of improvements in the way
some C++ operations are implemented, resulting in smaller, faster
code with fewer restrictions and less overhead. In some cases, the
new implementation is not fully compatible with previous ver-
sions of Borland C++. Where such compatibility is needed, the
following options are provided:
-Va When an argument of type class with constructors is
passed by value to a function, this option instructs the
compiler to create a temporary variable at the calling site,
initialize this temporary with the argument value, and
pass a reference to this temporary to the function. This
behavior is compatible with previous versions of Borland
C++. By default, Borland C++ copy-constructs such
argument values directly to the stack, thus avoiding the
introduction of the temporary (and also making access to
the argument value faster).
-Vb When a class inherits virtually from a base class, the
compiler stores a hidden pointer in the class object to
access the virtual base-class subobject. Borland C++
always makes this pointer near, which allows it to
generate more efficient code. For backward compatibility,
the -Vb option directs the compiler to match the hidden
pointer to the size of the this pointer used by the class
itself.
-Vc To correctly implement the case when a derived class
overrides a virtual function that it inherits from a virtual
base class, and a constructor or destructor for the derived
class calls that virtual function using a pointer to the
virtual base class, the compiler may add hidden members
to the derived class, and add mo!e code to its constructors
and destructors. This option directs the compiler not to
add the hidden members and code, so that class instance
layout is same as with previous versions of Borland C++.
-Vp This option directs the compiler to pass the this
parameter to pascal member functions as the first
parameter on the stack, for compatibility with previous
versions of Borland C++. By default, Borland C++ always
pushes this as the last parameter except when compiling
with the Object Data calling convention.
Chapter 5, The command-line compiler 173
174
Searching for
include and
library files
-Vt This option instructs the compiler to place the virtual
table pointer after any nonstatic data members of the
particular class, to ensure compatibility when class
instances are to be shared with non-C++ code and when
sharing classes with code compiled with previous
versions of Borland C++. By default, Borland C++ adds
this pointer before any nonstatic data members of the
class, thus making virtual member-function calls smaller
and faster.
-Vv This option directs the compiler not to change the layout
of any classes (which it may need to do in order to allow
pointers to virtual base class members, which were not
supported in previous versions of Borland C++). If this
option is used, the compiler can't create a pointer to a
member of a base class that can only be reached from the
derived class through two or more levels of virtual
inheritance.
-Vo This option is a "master switch" that turns on all of the
backward-compatibility options listed in this section. It
can be used as a handy shortcut when linking with
libraries built wIth older versions of Borland C++.
Borland C++ can search multiple directories for include and
library files. This means that the syntax for the library directories
(-L) and include directories (-I) command-line options, like that
of the #define option (-0), allows multiple listings of a given
option.
Here is the syntax for these options:
Library directories: -Ldirname[;dirname; ... ]
Include directories: -Idirname[;dirname; ... ]
The parameter dirname used with -L and -I can be any directory
or directory path.
You can enter these multiple directories on the command line in
the following ways:
You can "gang" multiple entries with a single -L or -I option,
separating ganged entries with a semicolon, like this:
Bee -Ldirnamel;dirname2;dirname3 -lincl;inc2;inc3 myfile.c
Borland C++ User's Guide
Note
File-search
algorithms
II You can place more than one of each option on the command
line, like this:
Bee -Ldirnamel -Ldirname2 -Ldirname3 -linel -line2 -line3 myfile.e
III You can mix ganged and multiple listings, like this:
Bee -Ldirnamel;dirname2 -Ldirname3 -linel;ine2 -line3 myfile.e
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.
The IDE also supports multiple library directories through the
"ganged entry" syntax.
The Borland C++ include-file search algorithms search for the
files listed in your source code in the follov.ring way:
EI If you put an #include <somefile.h> statement in your source
code, Borland C++ searches for somefile.h only in the specified
include directories.
13 If, on the other hand, you put an #include "somefile .h" state-
ment in your code, Borland C++ searches for somefile.h first in
the current directory; if it does not find the header file there, it
then searches in the include directories specified in the
command line.
The library-file search algorithms are similar to those for include
files:
IlJ Implicit libraries: Borland C++ searches for implicit libraries
only in the specified library directories; this is similar to the
search algorithm for #include <somefile.h>. (Implicit library files
are the ones Borland C++ automatically links in. These are the
Cx.LIB and CWx.LIB files, EMU. LIB or FP87.LIB, MATHx.LIB,
IMPORT.LIB, OVERLAY.LIB, and the start-up object files:
COx.OBJ, COWx.OBJ, and so forth.)
ill Explicit libraries: Where Borland C++ searches for explicit
(user-specified) libraries depends in part on how you list the
library file name. (Explicit library files are the ones you list on
the command line or in a project file; these are file names with a
.LIB extension.)
o If you list an explicit library file name with no drive or direc-
tory (like this: mylib.lib), Borland C++ searches for that
Chapter 5, The command-line compiler 175
176
An annotated
example
library in the current directory first. If the first search was un-
successful, it looks in the specified library directories. This is
similar to the search algorithm for #include "somefile.h" .
If you list a user-specified library with drive and/or directory
information (like this: c :mystuff\mylibl.lib), Borland C++
searches only in the location you explicitly listed as part of the
library path name and not in the specified library directories.
Here is an example of a Borland C++ command line that
incorporates multiple library and include-directory options.
1. Your current drive is C:, and your current directory is
C: \ BORLANDC, where BCC.EXE resides. Your A drive's
current position is A: \ASTROLIB.
2. Your include files (.h or "header" files) are located in
C: \ BORLANDC \ INCLUDE.
3. Your startup files (COT.OBJ, COS.OBJ, ... , COH.OBJ) are in
C:\BORLANDC.
4. Your standard Borland C++ library files (CS.LIB, CM.LIB, ... ,
MATHS.LIB, MATHM.LIB, ... , EMU. LIB, FP87.LIB, and so
forth) are in C:\BORLANDC\LIB.
5. Your custom library files for star systems (which you created
and manage with TLIB) are in C:\BORLANDC\STARLIB.
One of these libraries is P ARX.LIB.
6. Your third-party-generated library files for quasars a r ~ in the
A drive in \ASTROLIB. One of these libraries is W ARP.LIB.
Under this configuration, you enter the following command:
BCC '-rom -Llibjstarlib -linclude orion.c umaj.c parx.lib a:\astrolib\warp.lib
Borland C++ compiles ORION.C and UMAJ.C to .OBJ files,
searching C:\BORLANDC\INCLUDE for any #include files in
your source code. It then links ORION.OBJ and UMAJ.OBJ with
the medium model start-up code (COM.OBJ), the medium model
libraries (CM.LIB, MATHM.LIB), the standard floating-point
emulation library (EMU.LIB), and the user-specified libraries
(P ARX.LIB and WARP.LIB), producing an executable file named
ORION.EXE.
It searches for the startup code in C:\BORLANDC (then stops
because they're there); it searches for the standard libraries in
C:\BORLANDC\LIB (and stops because they're there).
Borland C++ User's Guide
When it searches for the user-specified library P ARX.LIB, the
compiler first looks in the current directory, C: \ BORLANDC. Not
finding the library there, the compiler then searches the library
directories in order: first C:\BORLANDC\LIB, then C:\
BORLANDC\STARLIB (where it locates PARX.LIB).
Since an explicit path is given for the library W ARP.LIB (A: \
ASTROLIB\ WARP.LIB), the compiler only looks there.
Chapter 5, The command-line compiler 177
178 Borland C++ User's Guide
A
p
Borland C++ is a professional
optimizing compiler that
gives you complete control
over what kinds of
optimization you want the
compiler to perform.
When should you
use the
optimizer?
In this appendix, "old"
versions of Borland C++ are
those before version 3.0 that
didn't contain the full
optimization features.
Appendix A, The Optimizer
p
N D x
A
The Optimizer
An optimizer is a tool for improving your application's speed or
shrinking down the application's size. It's not likely that the
optimizer will double or triple the speed of your application or
cut its size in half, but significant increases in speed or reductions
in size are common. It will allow you to program in the style you
find most convenient, not in the style that your computer finds
most' convenient.
There are several theories about the best use of the optimizer. One
theory is that you should never develop a new program with the
optimizer. Instead, you should compile with optimizations when
your application is in its final stages of development. This theory
is based on the fact that most compilers, when performing full
optimizations, take two to three times longer to compile than
when they are not performing any optimizations. Borland C++'s
optimizer, however, takes only 50% longer to compile when
performing full speed optimizations and 20% longer when
performing full size optimizations, so you don't have to worry
about slow compilation times.
Another theory says that you should always use the optimizer,
even in the early stages of development, since the optimizer may
reveal bugs in your code that do not appear when it is not opti-
mized. Opponents of this theory argue that debugging such
optimized code is a horrendous task not easily undertaken.
Borland C++'s Turbo Debugger understands optimized code and
179
allows you to easily debug your optimized application, giving
you the best of both worlds.
Optimization options
The -0 command line option controls most code optimizations.
The -0 option may be followed by one or more of the suboption
letters given in the list below. For example, -Oaxt turns on all
speed optimizations and assumes no pointer aliasing. You can
turn off optimizations on the command line by placing a minus
sign (-) before the optimization letter. For example, -02-p turns on
all speed optimizations except copy propagation. In addition,
some optimizations are controlled by means other than -0. For
example, -Z controls redundant load suppression.
The optimizations options follow the same rules for precedence as
all other Borland C++ options. For example, -Od placed on the
command line after a -02 would disable all optimizations.
Table Al: Optimization options summary
Command-line Function
-02 Options I Compiler I Optimizations I Full Speed
-Ox Generates the fastest code possible. This is the same as using the following
command-line options: -0 -Ob -Oe -Og -Oi -Ol-Om -Op -Ot -Ov -k--Z
-01 Options I Compiler I Optimizations I Full Size
Generates the smallest code possible. This is the same as using the following
command-line options: -0 -Ob -Oe -Ol-Os -k- -Z
-0 Options I Compiler I Optimizations I Optimize Jumps
Removes jumps to jumps, unreachable code, and unnecessary jumps
-Oa Options I Compiler I Optimizations I Assume no pointer aliasing
Assume that pointer expressions are not alia sed in common subexpression
evaluation
-Ob Options I Compiler I Optimizations I Dead code elimination
Eliminates stores into dead variables and conditional expressions whose values
can be determined at compiletime
-Oc Options I Compiler I Optimizations I Common Subexpressions I Optimize locally
Enables common sub expression elimination within basic blocks only. The -Oc
option and the -Og option are mutually exclusive
-Od Options I Compiler I Optimizations I No Optimizing
Disables all optimizations. Note that this is not the same as -0-, which merely
disables jump optimizations. It is equivalent to -O-cgbelmvpi -Z- -0-. Also
note that this option doesn't change the code-generation options for size (-Os)
or speed (-0).
180 Borland C++ User's Guide
Table Al: Optimization options summary (continued)
-Oe Options I Compiler I Optimizations I Global register allocation
Enables global register allocation and variable live range analysis
-Og Options I Compiler I Optimizations I Common Sub expressions I Optimize globally
Enables common sub expression elimination within an entire function. The -Og
option and the -Oc option are mutually exclusive
-Oi Options I Compiler I Optimizations I Inline intrinsics
Enables inlining of intrinsic functions such as memcpy, strlen, etc.
-01 Options I Compiler I Optimizations I Loop optimization
Compacts loops into REP /STOSx instructions
-Om Options I Compiler I Optimizations I Invariant code motion
Moves invariant code out of loops
-Op Options I Compiler I Optimizations I Copy propagation
Propagates copies of constants, variables, and expressions where possible
-Os Options I Compiler I Optimizations I Optimize for I Size
Makes code-selection choices in favor of smaller code
-Ot Options I Compiler I Optimizations I Optimize for I Speed
Selects code in favor of executable speed
-Ov Options I Compiler I Optimizations I Induction Variables
Enables loop-induction variable and strength-reduction optimizations
-Z Options I Compiler I Optimizations I Suppress redundant loads
Suppresses reloads of values which are already in registers
-po Options I Compiler I Optimizations I Object Data Calling
Enables the use of the Object Data calling convention for passing this in a
register to member functions.
-pr Options I Compiler I Entry /Exit Code I Calling Convention I Register
Enables the use of the _fastcall calling convention for passing parameters in
registers
Backward
compatibility
In addition to these new options, all the code-generation options
from Borland C++ 2.0 and Turbo C++ l.x are obeyed. Note,
however, that there is some duplication in the new and old
options. In parJicular, -G and -G- are -Os and -Ot, respectively.
In previous revisions, -Z performed load suppression but was
documented as enabling aliasing. The optimizer detects when one
register contains two expressions and suppresses extraneous
loads of expression "aliases." This action is not the same as the
aliases controlled by -Oa.
Appendix A, The Optimizer
For completeness, the old -r (register-optimization options) are
documented below.
181
-r This option enables the use of register variables (the
default).
Unless you are an expert, -r-
don't use -r-.
This option suppresses the use of register variables. When
y o ~ use this option, the compiler won't use register vari-
ables, and it won't preserve and respect register variables
(SI,DI) from any caller. For that reason, you should not
have code that uses register variables call code that has
been compiled with -r-.
A closer look at
the Borland C++
Optimizer
Global register
allocation
Dead-code elimination
182
On the other hand, if you are interfacing with existing
assembly-language code that does not preserve SI,DI, the
-r- option allows you to call that code from Borland c++.
-rd This option only allows declared register variables to be
kept in registers.
Conventional wisdom says there are three components to
generating good code on the 80x86 processors: register allocation,
register allocation, and register allocation.
Because memory references are so expensive on these processors,
it is extremely important to minimize those references through
the intelligent use of registers. Global register allocation both
increases the speed and decreases the size of your application.
You should always use global register allocation when compiling
your application with optimizations on.
Although you may never intentionally write code to do things
which are unnecessary, the optimizer may reveal possibilities to
eliminate stores into variables that are not needed. In the
following example, the optimizer creates a new variable to take
the place of the expression a [j l, thereby eliminating the need for
the variable j. Using -Ob will remove the code to store any result
into variable j.
int goo(void), a[10];
int f (void)
{
int i, j;
j = i = goo();
for( j = 0; j < 10; j++
a [ j] = goo () ;
Borland C++ User's Guide
Common
subexpression
elimination
Loop invariant code
motion
Appendix A, The Optimizer
return ii
Since the optimizer must determine where variables are no longer
used and where their values are needed (live range analysis), you
must use -Oe before using -Ob. Use -Ob whenever you use -Oe,
since -Ob always results in smaller and faster code.
Common subexpression elimination is the process of finding
duplicate expressions within the target scope and storing the
calculated value of those expressions once so as to avoid
recalculating the expression. Although in theory this optimization
could reduce code-size, in practice, it is a speed optimization and
will only rarely result in size reductions. You should also use
global common sub expression analysis if you like to reuse
expressions rather than create explicit stack locations for them.
For example, rather than code
temp = t->n.o.lefti
if(temp->op == O_ICON I I temp->op == O_FCON)
you could code
if(t->n.o.left->op == O_ICON I I t->n.o.left->op == O_FCON)
and let the optimizer decide whether it is more efficient to create
the temporary ..
If you find that global common subexpression elimination is
creating too many temporaries for your code-size requirements,
you can force common sub expression elimination to be done
within groups of statements unbroken by jumps (basic blocks) by
turning on local common sub expression elimination via the -Oc
option on the command line.
Moving invariant code out of loops is a speed optimization. The
optimizer uses the information about all the expressions in the
function gathered during common sub expression elimination to
find expressions whose values do not change inside a loop. To
prevent the calculation from being done many times inside the
loop, the optimizer moves the code outside the loop so that it is
calculated only once. The optimizer then reuses the calculated
value inside the loop. For example, in the code below, x * y * z is
evaluated in every iteration of the loop.
183
184
int v[10];
void f (void)
{
int i,x,y,z;
for (i = 0; i < 10; iff)
v[i] = x * y * z;
The optimizer rewrites the code for the loop so that it looks like:
int v[10];
void f (void)
{
int i,x,y,z,tl;
tl = x * y * Z;
for (i = 0; i < 10; iff)
v[i] = tl;
You should use loop invariant code motion whenever you are
compiling for speed and you have used global common
sub expressions, since moving code out of loops can result in
enormous speed gains.
Copy propagation Propagating copies is primarily speed optimization, but since it
never increases the size of your code, it is safe to use if you have
enabled -Og. Like loop invariant code motion, copy propagation
relies on the analysis performed during common sub expression
elimination. Copy propagation means that the optimizer remem-
bers the values assigned to expressions and uses those values
instead of loading the value of the assigned expressions. Copies of
constants, expressions, and variables may be propagated. In the
following code, for example, the constant value 5 is used in the
second assignment instead of the expression on the right side.
PtrParIn->IntComp = 5;
( *( PtrParIn->PtrComp ) ) . IntComp = PtrParIn->IntComp;
Pointer aliasing Pointer aliasing is not an optimization in itself, but it does affect
, the way the optimizer performs common sub expression
elimination and copy propagation. When pointer aliasing is
turned on, it allows the optimizer to maintain copy propagation
information across function calls and to maintain common
sub expression information across some stores. Otherwise, the
optimizer must discard information about copies and subexpres-
Bor/and C++ User's Guide
Appendix A, The Optimizer
sions in these situations. Pointer aliasing might create bugs that
are hard to spot, so it is only applied when you use -Oa.
-Oa controls how the optimizer treats expressions with pointers
in them. When compiling with global or local common
sub expressions and -Oa enabled, the optimizer recognizes
*p * x
as a common subexpression in function foo.
int g, Yi
int foo(int *p)
{
int X=5i
Y = *p * Xi
g = 3i
return (*p * x) i
void goo (void)
{
g=2i
, foo (&g) i /* This is incorrect, since the assignment g = 3
invalidates the expression *p * x */
-Oa also controls how the optimizer treats expressions involving
variables whose address has been taken. When compiling with
-Oa, the compiler assumes that assignments via pointers only
affects those expressions involving variables whose addresses
have been taken and which are of the same type as the lefthand
side of the assignment in question. To illustrate, consider the
following function.
int Y, Zi
int f (void)
{
int Xi
char *p = (char *)&Xi
y = x * Zi
*p = ' a';
return (X*Z)i
When compiled with -Oa, the assignment *p = ' a' does not
prevent the optimizer from treating x*z as a common
sub expression, since the destination of the assignment, *p, is a
185
Induction-variable
analysis and strength
reduction
186
char, whereas the addressed variable is an into When compiled
without -Oa, the assignment to *p prevents the optimizer from
creating a common sub expression out of x*z.
Creating induction variables and performing strength reduction
are speed optimizations performed on loops. The optimizer uses a
mathematical technique called induction to create new variables
out of expressions used inside a loop. These variables are called
induction variables. The optimizer assures that the operations
performed on these new variables are computationally less
expensive (reduced in strength) than those used by the original
variables.
Opportunities for these optimizations are common if you use
array indexing inside loops, since a multiplicatfon operation is
required to calculate the position in the array which is indicated
by the index. For example, the optimizer would create an
induction variable out of the operation v[il in the code below,
since the v [i 1 operation would require a multi"plication. This
induction variable also eliminates the need to preserve the value
of i.
int v[10];
void f(void)
{
int i,x,y,z;
for (i = 0; i < 10; iff)
v[i] = x * y * z;
With -Ov enabled, the optimizer would change this code to the
following:
int v[10];
void f (void)
{
int i,x,y,z, *p;
for (p = v; p < &v[10]; p++)
*p = x * y * z;
You should use -Ov whenever you are compiling for speed and
your code contains loops.
Borland C++ User's Guide
Loop compaction Loop compaction takes advantage of the string move instructions
on the 80x86 processors by replacing the code for a loop with such
an instruction.
Code size versus speed
optimizations
Structure copy inlining
Appendix A, The Optimizer
int v[100];
void t(void)
{
int i;
for (i = 0; i < 100; i++)
v[i] = 0;
The optimizer will reduce this to the machine instructions:
mov ex,100
mov di,offset DGROUP:_v
push ds
pop es
mmr i1Y,n
rep stosw
You should use -01 to compact loops whenever you are
generating code for speed.
Depending on the complexity of the operands, the compacted
loop code may also be smaller than the corresponding non-
compacted loop. You may wish to experiment with this
optimization if you are compiling for size and have loops of this
nature.
You can control the selection and compaction of instructions with
the -Ot and the -Os options. These options work like -G and -G-
in previous versions of Borland C++ but they have been enhanced
to do more. Most notable are the structure copy inlining and code
compaction optimizations. Whether you use -Ot or -Os depends
on what you are trying to achieve with your application.
The most visible optimization performed when compiling for
speed as opposed to size is that of inlining structure copies. When
you enable -Ot, the compiler determines whether it can safely
generate code to perform a rep movsw instruction instead of
calling a helper function to do the copy. For structures and unions
of over eight bytes in length, performing this optimization
produces faster structure copies than the corresponding helper
function call.
187
Code compaction The most visible optimization performed when compiling for size
is code compaction. In code compaction, the optimizer scans the
generated code for duplicate sequences. When such sequences
warrant, the optimizer replaces one sequence of code with a jump
to the other, thereby eliminating the first piece of code. switch
statements contain the most opportunities for code compaction.
Redundant load Load suppression is both a speed and size optimization. When -Z
suppression is enabled, the optimizer keeps track of the values it loads into
registers and suppresses loads of values which it already has in a
register. For example, when compiling the following code with-Z
enabled (and with copy propagation turned off), the optimizer
would push the value of *x it loaded into ES:BX instead of
reloading the value *x.
void f(void)
{
int *x = 5;
goo(*x) ;
You should always use this optimization whenever you are
compiling with the optimizer enabled.
Intrinsic function inlining There are times when you would like to use one of the common
string or memory functions, such as strcpy or memcmp, but you
do not want to incur the overhead of a function call. By using -Oi,
the compiler will generate the code for these functions within
your function's scope, eliminating the need for a function call. The
resulting code will execute faster than a call to the same function,
but it will also be larger.
188
The following is a list of those functions that are inlined when -Oi
is enabled.
mmemchr .. strcat II strncat II rotl
I'3memcmp EI strchr mstrncmp 1'1 rotr
amemcpy II strcmp II strncpy .fabs
mmemset II strcpy II strnset .. alloca
.. stpcpy strlen .. strrchr
You can control the inlining of each of these functions with the
pragma intrinsic. For example,
#pragrna intrinsic strcpy
Borland C++ User's Guide
Register parameter
passing
Appendix A, The Optimizer
would cause the cOlnpiler to generate inline code for all
subsequent calls to strcpy in your function.
#pragma intrinsic -strcpy
would prevent the compiler from inlining strcpy. Using these
pragmas in a file WIll override the command-line switches or IDE
options used to compile that file.
When inlining any intrinsic function, you must include a
prototype for that function before you use it. This is because when
inlining, the compiler actually creates a macro that renames the
inlined function to a function that the compiler recognizes
internally. In the above example, the compiler would create a
macro
#define strcpy __ strcpy __
The compiler recoenizes calls to functions with two leading and
two trailing underscores and tries to match the prototype of that
function against its own internally stored prototype. If you don't
supply a prototype or the prototype you supplied doesn't match
the compiler's internal prototype, the compiler rejects the attempt
to inline that function and generates an error.
Inlined intrinsic functions assume that the processor direction flag
is clear. This isn't a problem with code that Borland C++ gener-
ates, but if you use any assembly language routines, make sure
they" clean up" after themselves.
The Borland C++ compiler has two calling conventions where
parameters are passed in registers instead of on the stack: Object
Data and fastcall.
Object Data
With Object Data enabled, the compiler compiles member
functions to expect their this pointer to be passed in a register (or
a register pair in large data models). Likewise, calls to member
functions loads the register (or register pair) with this.
You can enable Object Data using the -po command-line option
or with the Options I Compiler I Optimizations I Object Data
Calling option. There is no language-specifier keyword.
In small data models, this is supplied in the 51 register; large data
models use D5:5I. If necessary, the compiler saves and restores
189
190
Y will use Object Data.
X won't use Object Data
since its class dec/oration
appeared before Object
Data was turned on.
D5. All references in the member function to member data are
done via the 51 register.
The names of member functions compiled with Object Data are
mangled differently from non-Object Data member functions, to
prevent mixing the two. It's easiest to compile all classes with
Object Data, but you can compile some classes with Object Data
and some without, as in the following example:
II no -po on the command-line
class X;
#pragma option -po
class Y : X
{
};
class X
};
#pragma option -po.
The _fasteall modifier
The compiler treats this calling convention as a new language
specifier, along the lines of _cdecl and _pascal. Functions
declared with either of these two languages modifiers cannot also
have the _fastcall modifier since they use the stack to pass
parameters. Likewise, the _fastcall modifier cannot be used
together with _export and _Ioadds. The compiler generates a
warning if you try to mix functions of these types or if you use the
_fastcall modifier in a dangerous situation. You may, however,
use functions using the _fastcall convention in VROOMM
overlaid modules.
Parameter rules
The compiler uses the rules given in Table A.2 when deciding
which parameters are to be passed in registers. A maximum of
three parameters may be passed in registers to anyone function.
You should not assume that the assignment of registers will
reflect the ordering of the parameters to a function.
Borland C++ User's Guide
Table A.2
Parameter types and
possible registers used
Appendix A, The Optimizer
Parameter Type
character (signed and unsigned)
integer (signed and unsigned)
long (signed and unsigned)
near pointer
Registers
AL,DL,BL
AX,DX,BX
DX:AX
AX,DX,BX
Far pointer, union, structure, and floating-point (float and double)
parameters are pushed on the stack.
Function naming
Functions declared with the _fastcall modifier have different
names than their non-_fastcall counterparts. The compiler
prefixes the _fastcall function name with an @. This prefix applies
to both unmangled C function names and to mangled C++
function names.
191
192 Borland C++ User's Guide
A
p
Table B.l
Editing commands
A word is defined as a
sequence of characters
separated by one of the
fol/owing: space < > , :
.()()II'*+-/$
#=I-?'''%&':
@ \, and aI/ control and
graphic characters.
p
Appendix B, Editor reference
E N D x
B
Editor reference
The editor has two command sets: CVA and Alternate. The tables
in this appendix list all the available commands. You can use
some commands in both modes, while others are available in only
one mode. Choose Options I Environment I Preferences and select
the command set you want in the Preferences dialog box.
Most of these commands need no explanation. Those that do are
described in the text following Table B.lo
Command
Cursor movement commands
Character left
Character right
Word left
Word right
Line up
Line down
Scroll up one line
Scroll down one line
Page up
Page down
Beginning of line
End of line
Top of window
Bottom of window
Top of file
Bottom of file
Move to previous position
Both modes CUA
(--
--7
Ctrl+ (--
Ctrl+ --7
l'
J.
Ctrl+W
Ctrl+Z
PgUp
PgDn
Home
Ctrl+QS
End
Ctrl+Q 0
Ctrl+Q E
Ctrl+Q X
Ctrl+Q R
Ctrl+Q C
Ctrl+Q P
Ctrl+E
Ctrl+X
Ctrl+Home
Ctrl+End
Alternate
Ctrl+S
Ctrl+D
Ctrl+A
Ctrl+F
Ctrl+E
Ctrl+X
Ctrl+R
Ctrl+C
Ctrl+Home
Ctrl+End
Ctrl+PgUp
Ctrl+PgDn
193
.l
Table B.l: Editing commands (continued)
Command Both modes CUA Alternate
Insert and delete commands
Delete character Del Ctrl+G
Delete character to left Backspace Ctrl+H
Shift+ Tab
Delete line Ctrl+Y
Delete to end of line Ctrl+Q Y Shift+Ctrl+ Y
Delete word Ctrl+T
Insert line Ctrl+N
Insert mode on/off Ins Ctrl+V
Block commands
Move to beginning of block Ctrl+QB
Move to end of block Ctrl+QK
Set beginning of block Ctrl+KB
Set end of block Ctrl+KK
Exit to menu bar Ctrl+K 0
Hide/Show block Ctrl+K H
Mark line Ctrl+K L
Print selected block Ctrl+K P
Mark word Ctrl+KT
Delete block Ctrl+K Y
Copy block Ctrl+KC
Move block Ctrl+K V
Copy to Clipboard Ctrl+lns
Cut to Clipboard Shift+Oel
Delete block Ctrl+Oel
Indent block Ctrl+K I Shift+Ctrl+1
Paste from Clipboard Shift+lns
Read block from disk Ctrl+K R Shift+Ctrl+R
Unindent block Ctrl+KU Shift+Ctrl+U
Write block to disk Ctrl+KW Shift+Ctrl+W
Marking blocks
Left one character S h i f t + ~
Right one character S h i f t + ~
End of line Shift+End
Beginning of line Shift+Home
Same column on next line Shift+ J,
Same column on previous line Shift+ l'
One page down Shift+PgOn
One page up Shift+PgUp
Left one word Shift+Ctrl+ ~
Right one word Shift+Ctrl+ ~
End of file Shift+Ctrl+End Shift+Ctrl+PgOn
Beginning of file Shift+Ctrl+Home Shift+Ctrl+PgUp
194 Borland C++ User's Guide
Block commands
The Persistent Blocks and
Overwrite Blocks options in
the Options I Environment I
Editor dialog box affect
some block operations. See
page 7 77 for more
information.
Appendix B, Editor reference
Table B.l: Editing commands (continued)
Command Both modes CUA Alternate
Other editing commands
Autoindent mode on/off Ctrl+O I
Cursor through tabs on/off Ctrl+OR
Exit the IDE Alt+F4 Alt+X
Find place marker Ctrl+Q n * GIrl n *
Help F1
Help index Shift+F1
Insert control character Ctrl+P*
Maximize window F5
Open file F3
Optimal fill mode on/off Gtrl+OF
. Pair matching Ctrl+Q [, Alt+[,Alt+j
Ctrl+Q j
Save file Ctrl+K S F2
Search Gtrl+Q F
Search again F3 Ctrl+L
Search and replace Ctrl+QA
Set marker Gtrl+K n * Shift+Ctrl n *
Tabs mode on/off Ctrl+O T
Topic search help Ctrl+F1
Undo Alt+Backspace
Redo Alt+Shift+Backspace
Unindent mode on/off Ctrl+O U
* n represents a number from 0 to 9.
** Enter control characters by first pressing Ctrl+P, then pressing the desired
control character.
A block of text is any amount of text, from a single character to
hundreds of lines, that is selected on your screen. There can be
only one block in a window at a time. Select a block with your
mouse or by holding down Shift while moving your cursor to the
end of the block with the arrow keys. Once selected, the block can
be copied, moved, deleted, or written to a file. You can use the
Edit menu commands to perform these operations or you can use
the keyboard commands listed in the following table.
When you choose Edit I Copy or press Ctrl+/ns, the selected block is
copied to the Clipboard. When you choose Edit I Paste or Shift+/ns,
the block held in the Clipboard is pasted at the current cursor
position. The selected text remains unchanged and is no longer
selected. '
195
If you choose Edit I Cut or press Shift+Del, the selected block is
moved from its original position and held in the Clipboard. It is
pasted at the current cursor position when you choose the Paste
command.
The copying, cutting, and pasting commands are the same in both
the CUA and Alternate command sets.
Table B.2; Block commands in depth
Command
Copy block
Copy text
Cut text
Delete block
Move block
Paste from
Clipboard
Read block
from disk
Write block
to disk
196
CUA
Ctrl+lns,
Shift+lns
Ctrl+lns
Shift+Del
Ctrl+Del
Shift+Del,
Shift+lns
Shift+lns
Shift+Ctrl+R
Ctrl+K R
Shift+Ctrl+ W
Ctrl+KW
Alternate
Ctrl+lns,
Shift+lns
Ctrl+lns
Shift+Del
Ctrl+Del
Shift+Del,
Shift+lns
Shift+lns
Ctrl+K R
Ctrl+KW
Function
Copies a previously selected block to the Clipboard
and, after you move your cursor to where you want the
text to appear, pastes it to the new cursor position. The
original block is unchanged. If no block is selected,
nothing happens.
Copies selected text to the Clipboard.
Cuts selected text to the Clipboard.
Deletes a selected block. You can "undelete" a
block with Undo.
Moves a previously selected block from its original
position to the Clipboard and, after you move your
cursor to where you want the text to appear, pastes it to
the new cursor position. The block disappears from its
original position. If no block is marked, nothing happens.
Pastes the contents of the Clipboard.
Reads a disk file into the current text at the cursor
position exactly as if it were a block. The text read is then
selected as a block. When this command is issued, you
are prompted for the name of the file to read. You can
use wildcards to select a file to read; a directory is
displayed. The file specified can be any legal file name.
Writes a selected block to a file. When you give this
command, you are prompted for the name of the file to
write to. The file can be given any legal name (the default
extension is CPP). If you prefer to use a file name without
an extension, append a period to the end of its name.
Borland C++ User's Guide
Table B.3
Borland-style block
commands
Selected text is highlighted
only if both the beginning
and end have been set and
the beginning comes before
the end.
Other editing
commands
If you have used Borland editors in the past, you may prefer to
use the block commands listed in this table; they work in both
command sets.
Command Keys Function
Set beginning of block Ctrl+K B Begin selection of text.
Set end of block Ctrl+K K End selection of text.
Hides/shows selected Ctrl+K H Alternately displays and hides selected
text text.
Copy selected text
to the cursor
Move selected text
to the cursor
Ctrl+K C Copies the selected text to the position
of the cursor. Useful only with the
Persistent Block option.
Ctrl+K V Moves the selected text to the position
of the cursor. Useful only with the
Persistent Block option.
The next table describes certain editing commands in more detail.
The table is arranged alphabetically by command name.
Table B.4: Other editor commands in depth
Command
Autoindent
Cursor through
tabs
Find place
marker
Open file
Optimal fill
Save file
CUA
Ctrl+O I
Ctrl+O R
Ctrl+n*
Ctrl+Q n*
Ctrl+O F
Appendix 8, Editor reference
Alternate
Ctrl+O I
Ctrl+O R
Ctrl+Q n*
F3
Ctrl+OF
F2
Function
Toggles the automatic indenting of successive lines. You can
also use Options I Environment I Editor Autoindent in the
IDE to turn automatic indenting on and off.
The arrow keys moves the cursor to the middle of tabs
when this option is on; otherwise, the cursor jumps several
columns when cursoring over multiple tabs. Ctrl+O R is a
toggle.
Finds up to 10 place markers (n can be any number in
the range 0 to 9) in text. Move the cursor to any previously
set.marker by pressing Ctrl+Q and the marker number.
Lets you load an existing file into an edit window.
Toggles optimal fill. Optimal fill begins every line with the
minimum number of characters possible, using tabs and
spaces as necessary. This produces lines with fewer
characters.
Saves the file and returns to the editor.
197
Table 8.4: Other editor commands in depth (continued)
Command CUA
Set place Shift+Ctrl n*
Ctrl+K n*
Show previous AIt+F7
error
Show next AIt+FB
error
Tab mode Ctrl+O T
Unindent Ctrl+O U
* n represents a number from 0 to 9.
198
Alternate Function
Ctrl+K n* Mark up to 10 places in text. After marking your location,
you can work elsewhere in the file and then easily return to
your marked location by using the Find Place Marker
command (being sure to use the same marker number). You
can have 10 places m a r ~ e d in each window.
AIt+F7 Moves the cursor to the location of the previous error or
warning message. This command is available only if there
are messages in the Message window that have associated
line numbers.
Alt+FB Moves the cursor to the location of the next error or
warning message. This command is available only if there
are messages in the Message window that have associated
line numbers.
Ctrl+O T Toggles Tab mode. You can specify the use of true tab
characters in the IDE with the Options I Environment I
Editor Use Tab Character option.
Ctrl+O U Toggles Unindent. You can turn Unindent on and off from
the IDE with the Options I Environment I Editor Backspace
Unindents option.
Borland C++ User's Guide
A
p p
E N D x
c
Using EasyWin
EasyWin is an exciting new feature of Borland C++ that lets you
compile standard DOS applications that use traditional "TTY
style" input and output so that they will run as true Windows
programs. Best of all, you don't have to change a single line of
code to use EasyWin.
DOS to Windows made easy
Appendix C, Using EosyWin
To convert your DOS applications that use stdio or iostream
functions, simply compile your program with the Windows
compiler switch (-W), or select Windows App from the Options I
Application dialog box in the IDE. Borland C++ will note that
your program does not contain a Win Main function (normally
required for Windows applications) and automatically link in the
EasyWin library. When you run your program in the Windows
environment, a standard window will be created, and your
program will take input and produce output for that window
exactly as if it were the standard screen.
Here's an example program:
#include <stdio.h>
main()
{
printf ("Hello, world\n") i
return 0 i
199
or, for C++, you could write
#include <iostream.h>
main()
{
cout "Hello, world\n";
return 0;
That's all there is to it. The EasyWin window is used anytime
input or output is requested from or to a TTY device. This means
that in addition to stdin, cin, stdout, and cout, the stderr, cerr, and
stdaux "devices" are all connected to this window.
Using EasyWin in a Windows application
200
EasyWin was designed to convert DOS programs to Windows
applications, quickly and easily. However; there may be reasons
for using EasyWin from within a "true" Windows application. For
example, you may want to add printf functions to your program
code to help you debug your Windows program. You can also use
EasyWin to help debug your ObjectWindows applications.
To use EasyWin from within a Windows program, simply make a
call to _lnitEasyWin somewhere in your application. It's easiest to
make the _lnitEasyWin call the first statement in your WinMain.
For example:
#include <windows.h>
#include <stdio.h>
#pragma argsused
int PASCAL WinMain(HANDLE hInstance, HANDLE hPrevInstance,
LPSTR IpszCmdLine, int cmdShow)
_Ini tEasyWin ( ) ;
/* Normal windows setup */
. printf("Hello, world\n");
return 0;
The prototype for _lnitEasyWin can be found in stdio.h, io.h, and
iostream.h.
Borland C++ User's Guide
Added functions
Limitations
absread
abswrite
allocmem
arc
bar
bar3d
bioscom
biosdisk
-
bios_disk
bioskey
_bios_keybrd
biosprint
_bios_printer
brk
cgets
circle
cleardevice
For your convenience, EasyWin also includes five additional
functions that allow you to specify the X and Y window
coordinates for input and output, clear the window, or clear to the
end of the current line. These functions are
III gotoxy
I:iIwherex
mwherey
13 clrscr
EI clreol
These functions have the same names (and uses) as functions in
conio.h (see the Library Reference). Classes in constrea.h provide
conio functionality for use with C++ streams (see Chapter 5,
"Using C++ streams," in the Programmer's Guide for a complete
discussion).
There are some functions a DOS program can call that aren't safe
for a Windows application to call. You won't be able to compile
such programs as EasyWin applications. You can't write any
program that uses graphics, hooks interrupts, or terminates and
stays resident. Run-time library functions that EasyWin doesn't
support are:
clearviewport exec Ie getarccoords getpalette
closegraph execlp getaspectratio getpalettesize
-
control87 execlpe getbkcolor getpass
coreleft execv getcolor gettext
cprintf execve getdefaultpalette gettextinfo
cputs execvp getdrivername gettextsettings
cscanf execvpe getfillpattern getviewsettings
delay farcoreleft getfillsettings getx
delline farheapcheck getgraphmode gety
detectgraph farheapcheckfree getimage graphdefaults
-
dos_allocmem farheapchecknode getlinesettings grapherrormsg
-
dos_freemem farheapfi Ilfree getmaxcolor _graphfreemem
_dos_keep farheapwalk getmaxmode _graphgetmem
-
dos_setblock fillellipse getmaxx graphresult
drawpoly fillpoly getmaxy harderr
ellipse floodfill getmodename
-
harderr
execl freemem getmoderange hardresume
Appendix C, Using EosyWin 201
-
hardresume linerel randbrd setfi Iistyle spawnlp
hardretn lineto randbwr setgraphbufsize spawnlpe
hardretn lowvideo rectangle setgraphmode spawnv
heapcheck moverel registerbgidriver setl i nestyle spawnve
heapcheckfree movetext registerbgifont setpalette spawnvp
heapchecknode moveto restorecrtmode setrgbpalette spawnvpe
heapfi Ilfree normvideo sbrk settextjustify system
heapwalk nosound sector settextstyle textattr
highvideo outtext setactivepage setusercharsize textbackgrourid
imagesize outtextxy setallpalette setviewport textcolor
initgraph
-
OvrlnitEms setaspectratio setvisualpage textheight
insline OvrlnitExt setbkcolor setwritemode textmode
-
installuserdriver pieslice setblock sleep textwidth
installuserfont putimage setcolor sound ungetch
keep putpixel _setcursortype spawnl window
line puttext setfill pattern spawnle
202 Borland C++ User's Guide
A
p p
How they work
E N D x
D
Precompiled headers
Borland C++ can generate and subsequently use precompiled
headers for your projects. Precompiled headers can greatly speed
up compilation times.
When compiling large C and C++ programs, the compiler can
spend up to half of its time parsing header files. When the
compiler parses a header file, it enters declarations and definitions
into its symbol table. If 10 of your source files include the same
header file, this header file is parsed 10 times, producing the same
symbol table every time.
Precompiled header files cut this process short. During one
compilation, the compiler stores an image of the symbol table on
disk in a file called TCDEF.SYM by default. (TCDEF.SYM is
stored in the same directory as the compiler.) Later, when the
same source file is compiled again (or another source file that
includes the same header files), the compiler reloads TCDEF.SYM
from disk instead of parsing all the header files again. Directly
loading the symbol table from disk is over 10 times faster than
parsing the text of the header files.
Precompiled headers will only be used if the second compilation
uses one or more of the same header files as the first one, and if a
Appendix 0, Precompiled headers 203
Drawbacks
lot of other things,like compiler options, defined macros and so
on, are also identical.
If, while compiling a source file, the compiler discoyers that the
first included files are identical to those of a previous compilation
(of the same source or a different source), it will load the binary
image for those files, and parse the remaining #include directives.
Use of precompiled headers for a given module is an all or
nothing deal: The precompiled header file is not updated for that
module if compilation of any included header file fails.
When using precompiled headers, TCDEF.5YM can become very
big, because it contains symbol table images for all sets of
included files encountered in your sources. You can reduce the
size of this file; see "Optimizing precompiled headers" on page
206.
If a header contains any code, then it can't be precompiled. For
example, while C++ class definitions may appear in header files,
you should take care that only member functions that are inline
are defined in the header; heed warnings such as "Functions
containing for are not expanded inline".
Using precompiled headers
204
You can control the use of precompiled headers in any of the
following ways:
from within the IDE, using the Options I Compiler I Code
Generation dialog box (see page 88). The IDE bases the name of
the precompiled header file on the project name, creating
PROJECT.SYM
from the command line using the -H, -H=filename, and -Hu
options (see page 166)
or from within your code using the pragmas hdrfile and
hdrstop (see Chapter 4 in the Programmer's Guide)
Borland C++ User's Guide
Setting file names
Establishing
identity
The compiler uses just one file to store all precompiled headers.
The default file name is TCDEF.SYM. You can explicitly set the
name with the -H=filename command-line option or the #pragma
hdrfile directive.
You may notice that your .sYM file is smaller than it should be. If
this happens, the compiler may have run out of disk space when
writing to the .SYM file. When this happens, the compiler deletes
the .sYM in order to make room for the .OBJ file, then starts
creating a new (and therefore shorter) .sYM file. If this happens,
just free up some disk space before compiling.
The following conditions need to be identical for a previously
generated precOIIlpiled header to be loaded ror a subsequent
compilation. -
The second or later source file must:
r.J have the same set of include files in the same order
r.J have the same macros defined to identical values
CI use the same language (C or C++)
E'l use header files with identical time stamps; these header files
can be included either directly or indirectly
In addition, the subsequent source file must be compiled with the
,same settings for the following options:
E'l memory model, including SS!= DS (-mx)
c underscores on externs (-u)
1:1 maximum identifier length (-iL)
Il target DOS (default) or Windows (-W or -Wx)
EiJ generate word alignment (-a)
c Pascal calls (-p)
II treat enums as integers (-b)
II default char is unsigned (-K)
CI virtual table control (-Vx)
Appendix 0, Precompiled headers 205
206
Optimizing
precompiled
headers
ASOURCE.C
BSOURCE.C
Revised BSOURCE.C
PREFIX.C
For Borland C++ to most efficiently compile using precompiled
headers, follow these rules:
Arrange your header files in the same sequence in all source
files.
!:II Put the largest header files first.
Prime TCDEF.SYM with often-used initial sequences of header
files.
Use #pragma hdrstop to terminate the list of header files at
well-chosen places. This lets you make the list of header files in
different sources look similar to the compiler. #pragma hdrstop
is described in more detail in Chapter 4 in the Programmer's
Guide.
For example, given the two source files ASOURCE.C and
BSOURCE.C, both of which include windows.h and myhdr.h,
#include <windows.h>
#include "myhdr.h"
#incl ude "xxx. h"
< ... >
#include "zz.h"
#include <string.h>
#include "myhdr.h"
#include <windows.h>
< ... >
You would rearrange the beginning of BSOURCE.C to:
#include <windows.h>
#include "myhdr.h"
#include "zz. h"
#include <string.h>
< ... >
Note that windows.h and myhdr.h are in the same order in
BSOURCE.C as they are in ASOURCE.C. You could also make a
new source called PREFIX.C containing only the header files, like
this:
#include <windows.h>
#include "myhdr.h"
Borland C++ User's Guide
If you compile PREFIX.C first (or insert a #pragma hdrstop in both
ASOURCE.C and BSOURCE.C after the #include "myhdr .h"
statement) the net effect is that after the initial compilation of
PREFIX.C, both ASOURCE.C and BSOURCE.C will be able to
load the symbol table produced by PREFIX.C. The compiler will
then only need to parse xxx.h for ASOURCE.C and zz.h and
string.h for BSOURCE.C.
Appendix 0, Precompiled headers 207
208 Borland C++ User's Guide
N
43/50-line display 114
<> (angle brackets) in #include directive 113
-2 BCC option (80286 instructions) 155
-3 BCC option (80386 instructions) 155
-1 BCC option (extended 80186 instructions)
155
(chevron) in dialog boxes 34
25-line display 114
; (semicolons) in directory path names 113
:: (System) menu 25, 46
- (tilde) in transfer program names 103
80x86 processors
instruction set 89
instructions 155
extended 155
$CAPEDITmacro 103
~ (arrows) in dialog boxes 34
-Ox BCC options (optimizations) 180
A
-a BCC option (align integers) 155
-A BCC option (ANSI keywords) 160
About command 130
activating, menu bar 25
Active File command 130
Add button 79
Add Item command 79, 133
Add Watch command 75
hot key 29
Advanced C++ Options command 95
Advanced Code Generation command 89
After Compiling option 105
aligning words and integers 87, 155
Alternate command set 39
American National Standards Institute See
ANSI
angle brackets in #include directive 113
Index
D E
ANSI
C standard 4
compatible code 160
floating point conversion rules 157
keywords
Borland C++, implementation-specific
option 160
using only 100
violations 101, 162
applications
x
transferring to and from Borland C++ 102
arguments
command-line compiler 145
passing to Turbo Debugger 64
variable list 158
Arguments command 63
Arrange Icons command 125
arrays
fast huge pointers 90, 158
inspecting values 70
arrows ( ~ s ) in dialog boxes 34
.ASM files See assembly language
assembler
compile via 88
default name 165
source file option 88
assembly language
assembling from the command line 145
compiling 166
directory 172
Wine routines 165
options
passing 167
removing 167
output files 167
projects and 138
assembly level debugger See Turbo Debugger
Assume No Pointer Aliasing option 98
Assume SS equals DS option 88
209
-AT BCe option (Borland C++ keywords) 161
-AU option (UNIX keywords) 161
Auto Save option 115
autoindent mode 195, 197
auto indent mode option 116
automatic dependencies 105
checking 137
information, disabling 159
Automatic Far Objects option 90
automatic variables See variables, automatic
B
-b BCC option (allocate whole word for enums)
155
-B BCC option (process inline assembler code)
165
Backspace Unindents option 116
Backward compatibility options 173
backward searching 57
.BAK files 116 .
bar, title 31
BBS segment See segments
BC and BCC See Borland C++; command-line
compiler; integrated environment
BCDEF.DPR files 38
BCDEF.DSK files 38
BGI See Borland Graphics Interface
BGIOBJ See The online document UTIL.DOC
block
copy 194, 196
Borland-style 197
cut 196
defined 195
delete 194, 196
extending 194
hide and show 194
Borland-style 197
indent 194
move 194, 196
Borland-style 197
move to beginning/end of 194
print 194
read from disk 194, 196
set beginning/end of 194
Borland-style 197
unindent 194
write to disk 194, 196
210
blocks, text See editor, block operations
boldface text 118
Borland
contacting 11
Borland C++
installing 14-18
quitting 25
Borland C++ for Windows 38
starting up 22
Borland Graphics Interface (BGI)
library 108
Break Make On
Make dialog box 135
option 105
breakpoints See also debugging; watch
expressions
clearing 77
controlling 76
deleting 76
editing 77
inline functions and 94
losing 77
saving across sessions 121
setting 76
viewing 76
Breakpoints command 76
Browse menu 81
browser
storing information 90
Browser Info in OBJs option 90
BSS names 102
build
IDE option (lb) 22
Build command 65
buttons
ObjectBrowser 81
Change All 58
choosing 34
in dialog boxes 34
mouse 121
radio 34
c
C++ Options command 93
-c BCC option (compile but don't link) 166
-C BCC option (nested comments) 161
Call Stack command 73
Borland C++ User's Guide
hot key 29
callbacks (smart)
Windows applications and 92
calling conventions 92
_fastcall 189
Cancel button 34
$CAP EDIT macro 103
Cascade command 125
case sensiti vi ty
exports option 107
librarian option 110
linking with 107
module definition file and 107
searches in 56
cdecl statement 158
.CFG files See configuration files
Change All button 58
Change Dir command 50
Change Directory dialog box 50
characters
char data type See data types, char
control
IDE and 35
delete 194
tab printing 51
Check Auto-dependencies option 105
check boxes 34
chevron symbol () 34
Class Inspector window 71
classes See also structures
browsing 82
debugging 71
inspecting 70
names 102
sharing objects 94, 169
classes arguments, passing by value 173
classes hierarchy, display of 82
Clear command 40, 54, 196
hot key 28
click speed (mouse) 120
Clipboard 53, 195
clearing 54
copy to 194
cut to 194
editing text in 55
paste from 194, 196
saving across sessions 121
Index
showing 55
Close All command 125
close boxes 31
Close command 125
hot key 28
Close Project command 79
code-generation
command-line compiler options 155
Code Generation command 86
Advanced command 89
Code Pack Size option 107
code segment
group 165
names 102
naming and renaming 164
storing virtual tables in 94, 169
-WD option and 167
colors
background 118
changing text 118
foreground 118
Colors dialog box 123
columns
numbers 30
COMDEFs
generating 156
PUBDEFs versus 90.
command-line compiler
options
emulate 80x87 (-f) 156
-f (emulate 80x87) 156
warnings (-wxxx) 162-164
command-line options, IDE 22
Command Set option 115
command sets 39
Alternate 39
Common User Access (CUA) 39
eVA and Alternate 26
Native 39
Native option 29,40
commands See also command-line compiler,
options; individual command names
choosing 25, 26
with the SpeedBar 41
editor
block operations 194, 195-196
cursor movement 193
211
insert and delete 194
comments, nested 100, 161
Common Subexpressions 99
No Optimization 99
Optimize Globally 99
Optimize Locally 99
Common User Access (CVA) command set 26,
39
communal variables 156
compilation 153, See also compilers
assembler source output 88
command-line compiler options 165
rules governing 150
speeding up 88
to .EXE file 65
to .OBJ file 64
Compile
command 40, 64
menu 64
Compile command
hot key 29
Compiler command 86
Compiler Messages submenu 101
compilers See also compilation
C++ 93
code optimization 97
command line See command-line compiler
configuration files See configuration files
memory models See memory models
optimizations for speed or size 99
stopping after errors and warnings 101
Compress Debug Info option 107
configuration files 36
command-line compiler 147, 151
crea ting 152
overriding 147, 152
priori ty rules 152
contents of 36
IDE 36-38
TCCONFIG.TC 36
saving 123
Borland C++ for Windows 41
constants
debugging 71
hexadecimal, too large 162
manifest See macros
octal, too large 162
212
Container class library 108
Contents command 129
hot key 28
control characters
entering in IDE 35
format specifier 74
inserting 195
Control menu 46
conventions, typographic 10
conversions
floating point, ANSI rules 157
pointers, suspicious 162
coprocessors See numeric coprocessors
Copy
command 40, 54
Example option 55, 129
Propagation option 98
copy
block (Borland-style) 197
protection 13
to Clipboard 194
Copy command
hot key 28
copyright information 130
CPP (preprocessor) See The online document
VTIL.DOC
.CPP files See C++
CPV registers 127
Create Backup Files option 116
Ctr1+Break 59, 60
CVA command set 26, 39
CVA option 115
Current Window option 115
Cursor Through Tabs option 116, 195, 197
customer assistance 11
customizing, IDE 114
Cut command 40, 54, 194
hot key 28
D
-D BCC option (macro definitions) 154
-d BCC option (merge literal strings) 156
data, aligning 87
data segments
group 164, 165
names 102
naming and renaming 164, 165
Borland C++ User's Guide
removing virtual tables from 94, 169
-WD option and 167
data types
char default 88
changing 157
floating point See floating point
integers See integers
Dead Code Elimination option 98
Debug Info in OBJs option 90
Trace Into command and 62
Debug menu 66
Debugger command 64, 110
Debugger Options command 64
debugging
arrays 70
breakpoints See breakpoints
Browser Info in OBJs 90
call stack 73
classes 70, 71
constants 71
Debug Info in OBJs 90
.DEF files and import libraries 104
dialog box choices 111
display swapping 111
dual monitors and 112
excluding information 80
expressions 71
format specifiers 72
functions 71
heap size 112
hot keys 29
information 60, 111
command-line compiler option 159
in .EXE or OBJ files 159
storing 90
inspecting values 68
line numbers information 89
pointers 69
stack overflow 93
starting a session 59
Step Over command 62
structures and unions 70
subroutines 92
Trace Into command 61
types 71
variables 71
Index
watch expressions See watch expressions
Windows applications 66
.DEF files, import libraries and 105
default assembler 166
default buttons 34
Default Extension option 117
Default Libraries option 106
#define directive
command-line compiler options 154
ganging 155
Defines option 88
Delete Item command 79, 133
Delete Watch command 75
deleting 194
deleting text (redoing/undoing) 53
dependencies 105
desktop
files (.DSK)
Borland C++ for Windows 41
saving options in 121
window, arranging icons in 125
Desktop option 115
Desktop Preferences dialog box 121
dialog boxes See also buttons; check boxes; list
boxes; radio buttons
arrows in 34
defined 33
entering text 35
Preferences 197
directories
.ASM and .OBJ command-line options 172
changing 50
defining 113
include files 147, 172, 174
example 176
libraries 175
command-line option 147, 172
example 176
output 113
project files 37
projects 134
semicolons in paths 113
source 113
Directories command 113
disk space, running out of 205
display
formats, debugger 72
213
repainting 46
swapping 111
dual monitors and 112
Display Warnings option 101
displays See screens
distribution disks 5
backing up 13
defined 14
DLLs See also import libraries
creating 92, 167
import libraries and 105
linker and 105
MAKE and 105
packing code segments 107
setting 106
DOS
output, viewing from IDE 126, 127
shelling to, TSRs and 51
wildcards 48
DOS Overlay command 91
DOS Shell command 25, 51
DOS Standard command 91
double-click speed (mouse) 120
DPMI, use of extended and expanded memory
17
DPMIINST, protected mode and 15, 146
DPMIMEM environment variable 16
DPMIRES protected mode utility 16
DS register (data segment pointer) 88
.DSK files
default 38
projects and 37
dual monitor mode 23
dual monitors
display swapping and 112
DOS command line and 51
Duplicate Strings Merged option 87
duplicate symbols 107
dynamic link libraries See DLLs
E
-E BCC option (assembler to use) 166
-e BeC option (EXE program name) .171
Edit See also editor
menu 52
windows
cursor, moving 193
214
loading files into 136
option settings 116
Edit Watch command 75
editing
hot keys 28
editing, copy and paste, hot key 28
editor
block operations 194, 195-196
deleting 196
deleting text 117
marking 117
overwrite 117
reading and writing 196
selecting blocks 52, 117
breakpoints 77
Clipboard text 55
commands
cursor movement 193
insert and delete 194
copy and paste hot keys 40
cut and paste 53, 54
insert mode, overwrite mode vs. 116
miscellaneous commands 197-198
options, setting 116
pair matching See pair matching
redoing undone text edits 53
selecting text 52, 195
setting defaults 116
tabs in 116
undelete 53
undoing text edits 53
watchpoints 75
Editor Files option 115
Editor Options 116
EGA See Enhanced Graphics Adapter
ellipsis ( ... ) 25, 33
EMS See also extended and expanded memory
emulation, 80x87 156
floating point 89
Enhanced Graphics Adapter (EGA) 114
palette
IDE option (/p) 24
Entry IExit Code command 91
enumerations (enum)
assigning integers to 162
treating as integers 87, 155
Borland C++ User's Guide
Environment
command 114
option, Auto Save 115
environment See integrated environment
errors See also warnings
ANSI 162
frequent 101, 163
IDE hot keys 29
messages 7
compile time 135
removing 137
saving 137
searching 59
setting 100
previous
hot key 29
reporting command-line compiler options
162
show next/previous 198
stopping on n 101
syntax, project files 135
tracking, project files 135
Errors, Stop After 101
Esc shortcut 34
Evaluate command, format specifiers and 72
Evaluate/Modify command 71
hot key 29
evaluation order
command-line compiler options 152
in response files 151
examples
copying from Help 55, 129
library and include directories 176
.EXE files
creating 27, 29, 65
directory 113
linking 65
making 40
naming 65
user-selected name for 171
executable files See .EXE files
Exit command 52
exiting
IDE 195
exiting Borland C++ 25
expanded memory 17, See extended and
expanded memory
Index
controlling use of 168
explicit library files 172
export (keyword) and Windows applications
91, 168
exports, case sensitive 107
expressions
debugging 71
evaluating restrictions on 72
values, displaying 72
extended 80186 instructions 155
extended 80386 instructions 155
extended dictionary option
librarian 110
extended memory 17, 18
IDE option (Ix) and 24
extension keywords, ANSI and 160
external
C++ virtual tables 93
External option
F
C++ Virtual Tables
command-line option 169
-f287 option (inline 80x87 code) 157
-f87 option (inline 80x87 code) 157
:....f BCC option (emulate 80x87) 156
_fastcall
calling convention 189
command-line option 158
Far Data Threshold type-in box 90
Far option
C++ Virtual tables 94
far variables 156
far virtual table segment
naming and renaming 165
Fast Floating Point option 90
fast huge pointers 90, 157
Fastest Code option 99
-Fc BeC option (generate COMDEFs) 156
features
Borland C++ 1
-Ff BCC option (far global variables) 156
-ff option (fast floating point) 90, 157
File menu 47
files See also individual file-name extensions
C++ See C++
closed, reopening 127
215
compiling 166
configuration 36
desktop (.DSK)
default 38
projects and 37
editing See editing
header See header files
HELPME!.DOC 14, 19
include See include files
information in dependency checks 137
informa tion on 66
library (.LIB) See libraries
loading into editor 136
make See MAKE (program manager)
map See map files
new 47
NONAME47
opening 47, 195, 197
choosing from List window 127
hot key 27
out of date, recompiled 137
printing 51
project 36
README 18
README.DOC 14
response See response files
saving 49, 195, 197
all 49
automatically 115
hot key 27
with new name or path 49
source, .ASM, command-line compiler and
145
filling lines with tabs and spaces 116
Find command 56, See also searching
Find dialog box
saving settings 123
Find Text dialog box 56
FIWRQQ89
floating point
ANSI conversion rules 157
code generation 89
fast 90, 157
format specifier 74
inline 80x87 operations 157
libraries 156
216
math coprocessor and 157
-Fm BCC option (enable -F options) 156
format specifiers
debugging and 72
table 74
43/50-line display 114
Frequent Errors, warnings 101
-Fs BCC option (assume DS = SS) 156
full link map 172
functions See also individual function names;
member functions
C-type 158
call stack and 73
calling conventions 92
exporting 167
Windows applications and 91, 167
Help 129
inline, precompiled headers and C++ 204
inspecting 71, 83
listing of 82
locating 59
searching for 59
stepping over 62
tracing into 61
void, returning a value 162
Windows 167
G
ganging
command-line compiler options
#define 155
macro definition 155
defined 155, 174
IDE 175
library and include files 175
Generate COMDEFs option 90
Generate Underbars option 89
Global Register Allocation option 98
global variables, word-aligning 155
-gn BCC option (stop on n warnings) 162
Go Cursor command 61
Go to Cursor command
hot key 27, 29
Go to Line Number command 59
Goto, ObjectBrowser 84
Graphics Library option 108
Borland C++ User's Guide
GREP (file searcher) See The online document
UTIL.DOC
wildcards in the IDE 56
group names 102
Group Undo option 116
Undo and Redo' commands and 53
H
-h BCC option (fast huge pointers) 157
-H BCC option (precompiled headers) 166
hardware requirements to run Borland C++ 4
with mouse 4
hdrfile pragma 204, 205
hdrstop pragma 204, 206
header files See, also include files
Help 129
precompiled See precompiled headers
searching for 175
variables and 90
heap size 112
Help
accessing 128
active file 130
button 34
C and c++ 129
Help on Help 130
Help on Help command 130
hot keys 27, 28
IDE option (lh) 23
index 129
keywords 128
language 129
menu 128
previous topic 130
status line 33
table of contents 129
windows
closing 128
copying from 129
keywords in 128
opening 128
selecting text in 128
help 195
HELPME!.DOC file 14, 19
index 195
topic search 195
Index
windows
copying from 55
hexadecimal numbers See numbers,
hexadecimal
hierarchies See classes
history lists 35
closing 125
saving across sessions 121
wildcards and 48
hot keys 40, 45
debugging 29
editing 28
help 27,28
menus 26, 27
using 26
huge pointers 157
-i BCC option (identifier length) 161
-I BCC option (include files directory) 147, 172
icons, arrangmg 125
IDE 21, See also integrated environment
command-line options 22
syntax 22
control characters and 35
starting up 22
identifiers
Borland C++ keywords as 100, 160
duplicate 107
length 100
Pascal-type 159
significant length of 155, 161
undefining 154
underscore for 158
$IMPLIB See import libraries
IMPLIB program See import libraries
implicit library files 172
import libraries See also DLLs
DLLsand 105
generating 105
#include directive See also include files
angled brackets and 175
directories 113
quotes and 175
Include Directories
input box 113
217
include files See also header files
command-line compiler options 175
directories 147, 172, 174
multiple 176
Help 129
projects 133
searching for 175
user-specified 147, 172
Include Files command 81, 133
incremental search 35
indentation block 194
indention
automatic 116
Index command
hot key 28
Index command (help) 129
Induction variables, option 98
Information command 66
initialization See .specific type of initialization
inline assembly code 165
inline code See assembly language, inline
routines
Inline Intrinsic Functions option 98
input boxes 35
insert lines 194
insert mode 194
Insert Mode option 116
Inspect
ObjectBrowser 84
command 68
Inspect command
hot key 28, 29
Inspector windows 68
arrays 70
Class 71
classes 70
constant 71
function 71
ordinal 69
pointers 69
structures and unions 70
Type 71
installation 14-18
laptop computers and 18
Instruction Set radio buttons 89
integers 155, See also floating point; numbers
aligned on word boundary 155
218
assigning to enumeration 162
integrated environment
command-line arguments and 63
customizing 19, 114
debugging See debugging
editor See editor
ganging 175
makes 137
menus See menus
multiple library directories 175
settings, saving 123
Invariant Code Motion option 98
italicize text 118
J
-jn BCC option (stop on n errors) 162
Jump Optimization option 98
K
-k BCC option (standard stack frame) 158
-K BCC option (unsigned characters) 157
K&R See Kernighan and Ritchie
Keep Messages command
toggle 137
Kernighan and Ritchie, keywords 100, 161
keyboard
choosing commands with 25, 34
selecting text with 52
keywords
L
ANSI command 160
Borland C++ 100
using, as identifiers 160
Help 129
Help windows 128
Kernighan and Ritchie, using 161
options 100
UNIX, using 161
-1 BCC option (linker options) 172
-L BCC option (object code and library
directory) 147, 172
language Help 129
laptop computers
installing Borland C++ onto 18
Borland C++ User's Guide
laptops
IDE option (11) 24
LCD displays
IDE option (11) 24
LCD screens
installing Borland C++ for 18
left-handed, mouse support 121
Less Frequent Errors dialog box 102
.LIB files See libraries
Librarian
case sensitive option 110
extended dictionary option 110
list file option 110
purge comments option 110
librarian
dialog box choices 110
Librarian command 110
Libr3.rian Options dialog box 110
libraries
command-line compiler options 175
container class 108
default 106
directories 113, 174
command-line option 147, 172
multiple 176
dynamic link (DLL) See DLLs
explicit and implicit 172
files 113, 147, 172
floating point 156
graphics 108
import See import libraries
linking 65
ObjectWindows 108
overriding in projects 141
rebuilding 159
routines, 80x87 floating-point emulation 157
runtime 109
searching for 175
user-specified 172
Library Directories input box 113
license statement 13
line numbers See lines, numbering
Line Numbers Debug Info option 89
lines
deleting 194
filling with tabs and spaces 116
inserting 194
Index
marking 194
moving cursor to 59
numbering 30
in object files 159
information for debugging 89
restoring (in editor) 53
Link command 65
link map, full 172
Linker
case sensitive linking 107
command 106
command-line compiler options 171, 172
container class library 108
DLLs and 105
link map, creating 172
options, from command-line compiler 172
linker, exclude from 80
list boxes 35
file names 48
searching incrementally 129
List command
hot key 28
list file option, librarian 110
List window 127
local
C++ virtual tables 93
Local Options
command 79, 133
local options
C++ virtual tables
command-line option 168
Local Options dialog box 79
Locate Function command 59
Loop Optimizations option 98
M
-M BCC option (link map) 172
macros
command-line compiler 154
ganging 155
preprocessor 88
transfer See transfer macros
Turbo editor See The online document
UTIL.DOC
MAKE (program manager)
After compiling 105
DLLs and 105
219
IDE option (1m) 24
integrated environment makes and 137
stopping makes 105, 135
Make command 65, 104
Make command, hot key 27, 29
manifest constants See macros
map files 172
directory 113
options 106
marker
find 195, 197
set 195, 198
math coprocessors See numeric coprocessors
maximize See Zoom command
member pointers, controlling 169
memory
dump, format specifier 74
expanded 17
controlling 168
IDE option (Ie) 23
extended 17
extended and expanded See extended and
expanded memory
heap size 112
protected mode and 15
memory models
automatic far data and'90
changing 87
command-line options 88, 153
smart callbacks and 167
menu bar See also menus
menu commands
choosing
with the SpeedBar 41
menus See also individual menu names
(IDE) 25
hot keys 26, 27
reference 45
with an ellipsis ( ... ) 33
Message Tracking toggle 136
Message window 125, 136
copying text from 54
removing messages 66
messages
appending 115
removing 66
Messages command 100
220
Microsoft Windows All Functions Exportable
command 91
Microsoft Windows applications
code segments 107
command-line compiler options 167
debugging 66
export functions and 91, 167
IDE options 91
optimizing for 99
prolog and epilog code 91
setting application type 106
setting options for 84, 91
setting Resource options for 114
smart callbacks and 92, 167
Microsoft Windows DLL All Functions
Exportable command 92
Microsoft Windows DLL Explicit Functions
Exported command 92
Microsoft Windows Explicit Functions
Exported command 92
Microsoft Windows Smart Callbacks command
92
. MODE command (DOS) 23
models, memory See memory models
module definition files
exported functions and 92
EXPORTS section, case-sensitive 107
IMPORTS section, case-sensitive 107
monitors See also screens
dual 51, 112
IDE option (I d) 23
number of lines 114
mouse
buttons (switching) 121
choosing commands with 26, 34
compatibility 4
double-click speed 120
left-handed support 121
options 120
reversing buttons 121
right button
browse with 81
right button action 120
selecting text with 52
mouse buttons
right and left 26
Mouse Double Click option 120
Bor/and C++ User's Guide
Mouse Options dialog box 120
moving text See editor
Multiple Document Interface (MDI) 38
multiple listings
command-line compiler options
#define 154
include and library 175
macro definition 154
-mx options (memory models) 153
N
-n BCC option (.OBJ and .ASM directory) 172
-N BCC option (stack overflow logic) 158
names See identifiers
Names command 102
Native command set 39
Native command set option 29,40
nested comments 161
Nested Comments option 100
New command 47
New Value field 72
New Window option 115
Next command 125
hot key 27, 28
next error, show 198
Next Error command 59
hot key 29
No-Nonsense License Statement 13
NONAME file name 47
numbers See also floating point; integers
decimal 112
format specifier 74
hexadecimal 112
constants, too large 162
format specifier 74
octal constants
too large 162
real See floating point
numeric coprocessors
. emulating 156
generating code for 157
inline instructions' 89, 157
o
-0 BCC option (object files) 166
Index
.OBJ files
browser information 90
compiling 166
creating 64
debugging information 90
dependencies 105
directories 113, 172
line numbers in 159
Object Data
parameter-passing sequence 158
Object Data Calling option 98
ObjectBrowser
choosing commands in 81
ObjectBrowser buttons 82
objects See also C++
far
class names 164
generating 90
group names 165
segment names 164
ObjectWindows library option 108
OBJXREF See The online document UTIL.DOC
octal numbers See numbers, octal
OK button 34
online help See help
Open a File dialog box 47, 197
Open command 47, 197
hot key 27, 28
open file 195, 197
Open Project command 78
opening a file 47
Optimal Fill option 116, 195, 197
Optimization 179
optimizations 97
command-line compiler options 160
Common Subexpressions 99
fast floating point 90
Fastest Code 99
for speed or size 99
No Optimizing 99
precompiled headers 206
register variables 98
registers, usage 181
Smallest Code 99
Windows applications and 99
221
options See also specific entries (such as
command-line compiler, options)
backward compatibility 173
C++ template generation
command-line option 171
Compress Debug Info 107
Options menu 84
settings, saving 123
ordinals, inspecting 69
Out-Line Inline Functions option 94
Output
command 126
Directory, input box 113
window
copying text from 54
output
to DOS, viewing from IDE 126, 127
User Screen 127
overlays
generating 159
projects and 80
supporting 91
Overview, ObjectBrowser 83
Overwrite Blocks option 117
Overwrite Mode 116
p
-P BCC option (C++ and C compilation) 166
-p BCC option (Pascal conventions) 158
-po BCe option (Object Data calling
convention) 158
-pr BCe option (fastcall calling convention) 158
Pack Code Segments option 107
pair matching 195
parameter-passing sequence
_fastca1l158
Object Data 158
Pascal 158
parameter types, register usage and 191
Pascal
calling convention 92
identifiers of type 159
parameter-passing sequence 158
Paste command 54
hot key 28
paste from Clipboard 194, 196
pasting See editor
222
path names in Directories dialog box 113
Persistent Blocks option 117
place marker
find 195, 197
set 195, 198
plasma displays, installing Borland C++ for 18
pointers .
fast huge 90, 157
format specifier 74
inspecting values 69
memory regions 74
suspicious conversion 162
virtual table
32-bit 94, 169
-WD option and 167
portability warnings 101, 163
#pragma hdrfile 204, 205
#pragma hdrstop 204, 206
precedence
command-line compiler options 147, 152
response files and 151
precompiled headers 203-207
command-line options 166
controlling 204
drawbacks 204
inline member functions and 204
optimizing use of 206
rules for 205
using, IDE 88
Preferences dialog box 197
previous error, show 198
Previous Error command 59
hot key 29
Previous Topic command 130
hot key 28
Print command 51
printer drivers 51
Printer Setup command 51
PRJ2MAK See The online document UTIL.DOC
.PRJ files See projects
PRJCFG See The online document UTIL.DOC
PRJCNVT See The online document UTIL.DOC
procedures See functions
Program Reset command 61
hot key 29
Programmer's Platform See integrated
environment
Borland C++ User's Guide
programs
ending 59
heap size 112
multi-source See projects
rebuilding 60, 65
resetting 61
running 59
arguments for 63
to cursor 61
Trace Into 61
transfer from Borland C++ 102
Project
command 127
menu 78
project files 36
contents of 36
Borland C++ for Windows 41
Project Ivb.nager 59
closing projects 79
Include files and 81
Project Name command 104
Project Notes
command 127
window 143
Project option 115
projects See also Project Manager
autodependency checking 105
speeding up 105 -
automatic dependency checking and 137
building 131
changing 38
closing 79
default 38
desktop files and 37, 36-38
directories 134
directory 37
error tracking 135
excluding from 80
.EXE file names and 65
files
adding 133
command-line options and 80
deleting 133
include 133
information 138
list 133
options 133
Index
out of date 137
viewing 143
IDE configuration files and 36
include files 133
information in 131
libraries and
overriding 141
loading and opening 37
makes and 137
making hot key for 135
managing 127
meaning of 78
naming 132
new 133
notes 127, 143
overlays and 80
saving 134
translator option 80
translators See also Transfer
default 138
example 139
multiple 138
options
changing 139
specifying 139
prolog and epilog code, generating 91
protected mode 15
command-line compiler 146
DPMIMEM variable 16
DPMIRES utility 16
pseudovariables, register
using as identifiers 161
PUBDEFs, COMDEFs versus 90
public
C++ virtual tables 94
Public option
C++ Virtual Tables
command-line option 169
pull-down menus See menus
purge comments option
librarian 110
Q
-Q BCC options (expanded memory) 168
Quit
command (IDE) 25
223
R
-r BCC option (register variables) 181
radio buttons 34
RAM disk
IDE option (lr) and 24
-rd option (register variables) 182
read block 194
README 18
README.DOC 14
rebuilding libraries 159
redo 195
Redo command 53
Group Undo and 53, 116
hot key 28
Register
command 127
keyword
option 99
registers
allocating 98
Automatic oRtion 99
DS (data segment pointer) 88
None option 98
pseudovariables, using as identifiers 161
SS (stack segment pointer) 88
usage and parameter types 191
variable optimization 98
variables
suppressed 181, 182
toggle 181, 182
windows 127
Remove All Watches command 76
Remove Messages command 66, 137
Repaint Desktop command 46
Replace
command 58
dialog box settings, saving 123
Replace Text dialog box 58
replacing a file 47
resetting programs 61
resize comer 31
Resources dialog box 114
response files
defined 151
option precedence 151
Result field 72
Reverse Mouse Buttons option 121
224
Rewind, ObjectBrowser 83
Right Mouse Button option 120
Run
command 59
menu 59
Run command
hot key 29
runtime library option 109
5
-s BCC option (produce .ASM but don't
assemble) 167
sample programs, copying from Help window
55
Save All command 49
Save As command 49
Save command 49, 123
hot key 27, 28
save file 195, 197
Save File As dialog box 49
Save Old Messages option 115
scope See also variables
Screen Size option 114
screens
LCD
installing Borland C++ for 18
number of lines 114
plasma, installing Borland C++ for 18
repainting 46
scroll bars 31, 32
Search Again command 58
hot key 28
Search menu 56
searching
direction 57
error and warning messages 59
for text 195
functions 59
in list boxes 129
include files 175
libraries 175
origin 57
regular expressions 56
repeating 58
replace and 58
scope of 57
search and replace 58
Borland C++ User's Guide
Segment Alignment option 107
segment-naming control
command-line compiler options 164
segments
aligning 107
code
minimizing 107
packing 107
controlling 164
ini tializing 106
names 102
selecting text 195
semicolons (;) in directory path names 113
Set Application Options dialog box 84
shortcuts See hot keys
Show Clipboard command 55
Size/Move command 124
Smallest Code option 99
smart
C++ virtual tables 93
smart callbacks
memory models and 167
Windows applications and 167
Smart option
C++ Virtual Tables
command-line option 169
smart option
C++ virtual tables
command-line option 168
software See programs
software license agreement 13
software requirements to run Borland C++ 4
Source command 100
Source Debugging command 60
and Trace Into command 62
Source Directory, input box 113
source files
.ASM, command-line compiler and 145
directory 113
source-level debugger See Turbo Debugger
. Source Options dialog box 100
Source Tracking options 115, 136
spaces vs. tabs 116
SpeedBar 41
configuring the 41
SS register (stack segment pointer) 88
Index
stack
Call Stack command 73
overflow 93, 158
standard frame, generating 158
warnings 107
standalone librarian
case sensitive 110
extended dictionary 110
list file 110
purge comments 110
standard library files See libraries
Standard Stack Frame
command 92
generating 158
option 73, 98
start-up and exit
IDE 22
Startup Preferences dialog box 121
status line 33
Step Over command 62
hot key 27, 29
strings.
duplicate, merging 87
format specifier 74
literal, merging 156
structures
ANSI violations 162
format specifier 74
inspecting 70
undefined 162
zero length 162
Suppress redundant load option 98
swapping
displays 111
switch to another program 51
switches See command-line compiler, options;
integrated environment
.5YM files 203, 204
default names 204
disk space and 205
smaller than expected 205
symbolic constants See macros
symbolic debugger See Turbo Debugger
symbols, duplicate 107
syntax
errors, project files 135
IDE command line 22
225
System menu ( :: ) 25, 46
system requirements 4
T
-T- BCC option (remove assembler options)
167
'this' pointer in 'pascal' member functions 173
Tab mode 198
Tab Size option 117
tabs
characters, printing 51
size of 117
spaces vs. 116
using in the editor 116
Tabs mode 195
TCeONFIG.TC See configuration files, IDE
TCDEP.5YM 166, 203, 204, See also .SYM files
technical support 11
TEML See The online document UTIL.DOe
Template Generation option 94
templates, generation 170
terminate and stay resident See TSR programs
Test Stack Overflow command 93
text See also editor
blocks See editor, block operations
copy and paste 54
cutting 54
deleting 54
entering
in dialog boxes 35
inserting vs. overwriting 116
pasting 54
restoring (in editor) 53
screen display of 114
selecting 52
Help window 128
The Highlighting dialog box 118
THELP See The online document UTIL.DOe
thrash control
IDE (Is) and 24
threshold size
far global variables, setting 156
thunks See smart callbacks
tilde (-) in transfer program names 103
Tile command 124
hot key 28
title bars 31
226
Toggle Breakpoint command 76
hot key 29
Topic Search command 129
hot key 28
Topic search in Help 195
Trace Into command 61
Debug Info in OBJs option and 62
hot key 27, 29
Source Debugging command and 62
Transfer
command 25, 102
dialog box 102
programs 46
editing 103
transfer macros 103
transfer to another program 51
Translator option 80, 104
translators See projects, translators
Treat enums as ints option 87
TRIGRAPH See The online document
UTIL.DOe
TSR programs, shelling to DOS and 51
- Tstring Bec option (pass string to assembler)
167
Turbo Assembler
Borland C++ command-line compiler and
150
command-line compiler and 145
default 166
invoking 150
Turbo Debugger, described 159
Turbo Debugger for Windows 64
Windows applications and 66
Turbo Editor Macro Language compiler See
The online document UTIL.DOe
TURBOC.CFG 151
25-line display 114
typefaces used in these books 10
types
debugging 71
typographic conventions 10
u
-U BCC option (undefine) 154
-u BeC option (underscores) 158
underline text 118
underscores 159
Borland C++ User's Guide
generating automatically 89, 158
undo 195
Undo command 53
Group Undo and 53, 116
hot key 28
unindent
block 194
mode 195, 198
unions
format specifier 74
inspecting 70
UNIX
keywords 100
using 161
porting Borland C++ files to 161
Unsigned Characters option 88
Use Tab Character option 116
User Screen
hot key 28
User Screen command 127
user-specified library files 172
utilities See also The online document
UTIL.DOC
v
-v and -Vn BCC options (C++ virtual tables)
168
-v BCC option (debugging information) 159
-Va BCe option (class argument compatibility)
173
-Vb BCe option (virtual base class pointer
compatibility) 173
-V c BCC option (derived class with pointer to
inherited virtual base class member function)
173
-Vm BCe options (C++ member pointers) 169
-Vp BCe option ('this' pointer in 'pascal'
member functions compatibility) 173
-Vt BCC option (virtual table pointers) 173
-Vv BCC option (pointers to virtual base class
members) 174
variable, inspecting a 83
variable argument list 158
variables
automatic word-aligning 155
communal 156
debugging 71
Index
global, far 156
header files and 90
inspecting values of 68
list of 83
register 181, 182
version number information 130
-vi option (C++ inline functions) 160
Video Graphics Array Adapter (VGA) 114
virtual base class, hidden pointer to 173
virtual base class members, pointers to 174
virtual functions
hidden members in derived classes with
pointers to 173
virtual table pointers, c01!1patibility 173
virtual tables 93
32-bit pointers and 94, 169
-WD option and 167
controlling 168
storing in the code segment 94, 169
-WD option and 167
w
-W BeC options (Windows applications) 167
-wxxx BCC options (warnings) 162
warnings See also errors
ANSI Violations 101
C++ 101, 163
command-line options 162-164
enabling and disabling 162
frequent errors 101,163
messages 7
options 162-164
portability 101, 163
Warnings, Stop After 101
watch expressions
adding 75
controlling 75
deleting 75, 76
editing 75
saving across sessions 121
watch window 126
Watches command' 75
-WD BCe options (.DLLs with all exportables)
167
-WDE BCe options (.DLLs with explicit
exports) 167
227
-WE Bee options (.OBJs with explicit exports)
167
whole-word searching 56
wildcards 56
DOS 48
GREP 56
Window menu 124
windows
cascading 125
Clipboard 55
closed 127
listing 128
closing 125
Edit See Edit, windows
Help See Help, windows
Inspector 68
List All 127
Message 66, 125
moving 124
next 125
open 127
listing 128
Output 126
Project 127
Project Notes 127
Register 127
resizing 124
saving across sessions 121
source tracking 115
swapping in debug mode 111
dual monitors and 112
tiling 124
228
User Screen 127
using IDE 28,30,31,32,33
Watch 126
zooming 124
Windows (Microsoft) See Microsoft Windows
word
delete 194
mark 194
Word Alignment option 87, 155
write block 194
-WS Bee options (smart callbacks) 167
-wxxx BCe option (warnings) 162
-wxxx Bee options (warnings) 162-164
x
-x BCe option (disable autodependency
information) 159
y
-y Bee option (line numbers) 159
- Y Bce option (overlays) 159
-Yo BCC option (overlays) 159
z
zoom box 31
Zoom command 124
hot key 27, 28
-zV options (far virtual table segments) 165
-zX options (code and data segments) 164, 165
Borland C++ User's Guide
3.1
B o R L A N D
Corporate Headquarters: t800 Green Hills Road, P.O. Box 660001 , Scotts Valley, CA 95067-0001 , (408) 438-5300. Offices in: Australia,
Belgium, Canada, Denmark, France, Gennany, Hong Kong, Italy, Japan, Korea, Malaysia, Netherlands, New Zealand, Singapore, Spain,
Sweden, Taiwan and Untted Kingdom. Part #14MN-BCP01-31 BOR 3860

You might also like