This document provides an overview and details about the Turbo C compiler from Borland. Some key points:
- Turbo C was an integrated development environment and compiler for C released by Borland in 1987 that was known for its fast compile speed and low price.
- It included an editor, compiler, libraries and debugger. Versions included Turbo C 1.0 through 2.0 before being replaced by Turbo C++.
- The compiler produced four types of messages: fatal errors, errors, warnings and informational. Errors indicated issues like syntax errors while warnings did not prevent compilation.
- Details are provided on the Turbo C editor, libraries, include files, customization options,
1. Turbo C Compiler
Chapter 1
INTRODUCTION
1.1 Overview of Background
In the early 1980s, Borland enjoyed considerable success with their Turbo Pascal product
and it became a popular choice when developing applications for the PC.
Borland followed up that success by releasing Turbo Basic, Turbo Prolog and Turbo C.
Turbo C had the same properties as Turbo Pascal: an integrated development environment
(IDE), a fast compiler, a good editor and a competitive price.
Turbo C was not as successful as the Pascal-sister product. First, C was a language for
professional programming and systems development rather than a school language.
Turbo C competed with other professional programming tools (Microsoft C, Lattice C,
Watcom C, etc.). Turbo C did, however, have advantages in speed of compiled code, large
project support and price. It is developed in C.
RVCE 1
2. Turbo C Compiler
Chapter 2
Chapter 2
BORLAND TURBO C
Turbo C is an Integrated Development Environment and a compiler for the C programming
language from Borland. First introduced in 1987, it was noted for its integrated
development environment, small size, fast compile speed, comprehensive manuals and low
price.
In May 1990, Borland replaced Turbo C with Turbo C++. In 2006, Borland reintroduced the
Turbo moniker.
The name "Turbo C" was not used after version 2.0, because with the release of Turbo C++
1.0 with 1990, the two products were folded into a single product. That first C++ compiler
was developed under contract by a company in San Diego and was one of the first true
compilers for C++ (until then, most C++ work was done with pre-compilers that generated C
code). The next version was named Borland C++ to emphasize its flagship status and
completely rewritten in-house, with Peter Kukol as the lead engineer. The Turbo C++ name
was briefly dropped, eventually reappearing as Turbo C++ 3.0. There was never a 2.0 of the
Turbo C++ product series.
Borland split the product (and later Pascal) in two lines, one for beginners and one for
professionals. At first they were called "Turbo and Turbo Professional, later simply have
"Turbo" and "Borland". They developed C++ in 1996 in these two lines next to the version of
Turbo C++ 3.0 and Borland C++ 5.0. As with Turbo Pascal, there was also a Turbo C++ for
Microsoft windows, which reached version 4.5.
Turbo C for the Atari ST ended with version 2.0. The program was not maintained by
Borland, but the product was sold and renamed PureC.
From 1996, Delphi became Borland's principle and highly successful Pascal toolkit. A similar
release based on C++ became Borland C++Builder, which replaced Borland C++.
RVCE 2
3. Turbo C Compiler
2.1 Versions of Borland Turbo C
1987: Turbo C 1.0
1987: Turbo C 1.1
1988: Turbo C 1.5
1989: Turbo C 2.0
1990: Turbo C++ 1.0
1991: Turbo C++ 1.01
1991: Turbo C++ 2.0
1992: Turbo C++ 3.0
Version 1.0
Released on May 13, 1987, offered the first integrated edit-compile-run development
environment for C on IBM PCs. The software was, like many Borland products of the time,
bought from another company and branded with the "Turbo" name, in this case Wizard C by
Bob Jervis (Borland's flagship product at that time, Turbo Pascal, which at this time did not
have pull-down menus, would be given a facelift with version 4 released late in 1987 to
make it look more like Turbo C.) It ran in 384 kB of memory. It allowed inline assembly with
full access to C symbolic names and structures, supported all memory models, and offered
optimizations for speed, size, constant folding, and jump elimination.
Version 1.5
in January 1988 was an incremental improvement over version 1.0. It included more sample
programs, improved manuals and bug fixes. It was shipped on five 360 KB diskettes of
uncompressed files, and came with sample C programs, including a stripped down
spreadsheet called mcalc. This version introduced the <conio.h> header file (which provided
fast, PC-specific console I/O routines.
Version 2.0
In 1989 was released was in late 1988, and featured the first "blue screen" version, which
would be typical of all future Borland releases for MS-DOS. The American release did not
RVCE 3
4. Turbo C Compiler
have Turbo Assembler or a separate debugger. (These were sold separately as Turbo
Assembler.) Turbo C, Asm, and Debugger were sold together as a suite. This seems to
describe another release: Featured Turbo Debugger, Turbo Assembler, and an extensive
graphics library. This version of Turbo C was also released for the Atari ST, but distributed
in Germany only.
2.2 Turbo C Library Routines
Turbo C comes equipped with over 300 library routines-functions and macros that you call
from within your C programs to perform a wide variety of tasks, including low- and high-
level I/O, string and file manipulation, memory allocation, process control, data conversion,
mathematical calculations, and much more.
Turbo C's routines are contained in the library files (Cx.LIB and MATHx.LIB). Because Turbo C
supports six distinct memory models, each model has its own library file and math file,
containing versions of the routines written for that particular model.
Turbo C supports the draft ANSI C standard which, among other things, al!().ws function
prototypes to be given for the routines in your C programs. All of Turbo C's library routines
are declared with prototypes in one or more header file (these are the .H or "include" files
that you copied from the distribution disks into your INCLUDE directory).
2.3 Turbo C Include Files
ALLOC.H- Declares memory management functions (allocation, deallocation, etc.).
BIOS.H- Declares various functions used in calling IBM-PC ROM BIOS routines
CONIO.H- Declares various functions used in calling the DOS console I/O routines.
CTYPE.H- Contains information used by the character classification and character
conversion macros (such as is alpha and to ASCII).
MATH.H- Declares prototypes for the math functions; also defines the macro
HUGE_VAL, and declares the exception structure used by the matherr and _matherr
routines.
STDLIB.H- Declares several commonly used routines; conversion routines,
search/sort routines, and other miscellany.
RVCE 4
5. Turbo C Compiler
2.4 Language Syntax Summary
This appendix uses a modified Backus-Naur Form to summarize the syntax for Turbo C
constructs. These constructs are arranged categorically, as follows:
Lexical Grammar:
tokens, keywords, identifiers, constants, string literals, operators and punctuators
Phrase Structure Grammar:
expressions, declarations, statements, external definitions
Preprocessing directives
2.5 Customizing Turbo C
Turbo C comes ready to run, as soon as you make working copies of the disk files. There is
no installation, per se. But you do have the option of changing many of Turbo C's default
modes of operation by running this customization program. This program, TCINST.COM, lets
you do six things:
set up a path to your configuration and Help files
customize your Editor commands
modify your default edit modes
set up your default screen mode
change your screen colors
change the size of Turbo C's windows
If you want to store your help (TCHELP.TCH) or configuration files (TCCONFIG.TC) in a
directory other than the one where you do your work, you'll need to use the Turbo C
directory option to set a path to those files.
If you're either unfamiliar with Turbo C's editor or inexorably tied to another editor, you can
use the Editor commands option to reconfigure (customize) the editor keystrokes to your
liking.
You can also use the Default editor mode option to set several defaults for the editor. You
can choose to
RVCE 5
6. Turbo C Compiler
load and save a pick list
work in insert or overwrite mode
turn tabs on or off
work with auto-indent on or off
You can set up the display mode that Turbo C will use when it is in operation and specify
whether you have a "snowy" video adapter. You can customize the colors of almost every
part of the Turbo C screen output. And finally, you can change the default sizes of the Edit
and Message windows.
RVCE 6
7. Turbo C Compiler
Chapter 3
TURBO C INTERACTIVE EDITOR
Turbo C's built-in editor is specifically designed for creating program source text. If you are
familiar with the Turbo Pascal or SideKick editor, or MicroPro's WordStar program, you
already know how to use the Turbo C editor, since its commands are almost identical to one
of these editors. A section at the end of this appendix summarizes the few differences
between Turbo C's editor commands and WordStar's commands. The Turbo C editor, unlike
WordStar, has a "restore" facility that lets you take back changes if you haven't yet left the
line. This command (Ctrl-Q L) is described in "Miscellaneous Editing Commands."
Quick In, Quick Out
To invoke the editor, choose Edit from Turbo C's main menu. The Edit window becomes the
"active" window; the Edit window's title is highlighted and the cursor is positioned in the
Edit window. To enter text, type as though you were using a typewriter. To end a line, press
the Enter key. To invoke the main menu from within the editor, press F10 (the data in the
Edit window remains on screen).
3.1 Editor Commands
The editor uses approximately 50 commands to move the cursor around, page through text,
find and replace strings, and so on. These commands can be grouped into four main
categories:
cursor movement commands (basic and extended)
insert and delete commands
block commands
miscellaneous commands
RVCE 7
8. Turbo C Compiler
3.2 The Turbo C Editor Vs. WordStar
A few of the Turbo C editor's commands are slightly different from WordStar. Also, although
the Turbo C editor contains only a subset of WordStar's commands, several features not
found in WordStar have been added to enhance program source-code editing. These
differences are discussed here, in alphabetical order.
Autoindent
The Turbo C editor's Ctr/-O / command toggles the autoindent feature on and off.
Carriage returns
In Turbo C, carriage returns cannot be entered at the end of a file in Overwrite mode. (If
you press Enter at the end of a line when Insert mode is off, the editor will not insert a
carriage return character or move the cursor to the next line.) To enter carriage returns, you
can either switch to Insert mode or use Ctr/-N in Overwrite mode.
Cursor movement
Turbo C's cursor movement controls-Ctr/-S, Ctr/-O, Ctr/-E, and Ctr/X- move freely around on
the screen without jumping to column one on empty lines. This does not mean that the
screen is full of blanks, on the contrary, all trailing blanks are automatically removed. This
way of moving the cursor is especially useful for program editing, for example, when
matching indented statements.
Delete to left
The WordStar sequence Ctr/-Q Oe/, delete from cursor position to beginning of line, is not
supported.
Mark word as block
Turbo C allows you to mark a single word as a block using Ctr/-K T. This is more convenient
than WordStar's two-step process of separately marking the beginning and the end of the
word.
RVCE 8
9. Turbo C Compiler
Movement across line breaks
Ctr/-S and Ctr/-O do not work across line breaks. To move from one line to another you
must use Ctr/-E, Ctr/-X, Ctr/-A, or Ctr/-F.
Quit edit
Turbo C's Ctr/-K Q does not resemble WordStar's Ctr/-K Q (quit edit) command. In Turbo C,
the changed text is not abandoned-it is left in memory, ready to be compiled and saved.
Undo
Turbo C's Ctr/-Q L command restores a line to its pre-edit contents as long as the cursor has
not left the line.
RVCE 9
10. Turbo C Compiler
Chapter 44
Chapter
COMPILER ERROR MESSAGES
The Turbo C compiler diagnostic messages fall into three classes
1. Fatal
2. Errors
3. Warnings.
Fatal errors are rare and probably indicate an internal compiler error. When a fatal error
occurs, compilation immediately stops. You must take appropriate action and then restart
compilation. Errors indicate program syntax errors, disk or memory access errors, and
command line errors. The compiler will complete the current phase of the compilation and
then stop. The compiler attempts to find as many real errors in the source program as
possible during each phase (preprocessing, parsing, optimizing and code-generating).
Warnings do not prevent the compilation from finishing. They indicate conditions which are
suspicious, but which are legitimate as part of the language. Also, the compiler will produce
warnings if you use machinedependent constructs in your source files. The compiler prints
messages with the message class first, then the source file name and line number where the
compiler detected the condition, and finally the text of the message itself. In the following
lists, messages are presented alphabetically within message class. With each message, a
probable cause and remedy are provided. You should be aware of one detail about line
numbers in error messages: the compiler only generates messages as they are detected.
Because C does not force any restrictions on placing statements on a line of text, the true
cause of the error may be one or more lines before the line number mentioned. In the
following message list, we have indicated those messages which often appear (to the
compiler) to be on lines after the real cause.
4.1 Fatal Errors
Bad call of in-line function
You have used an in-line function taken from a macro definition, but have called it
incorrectly. An in-line function is one that begins and ends with a double underbar (
__ ).
RVCE 10
11. Turbo C Compiler
Irreducible expression tree
This is a sign of some form of compiler error. Some expression on the indicated line
of the source file has caused the code generator to be unable to generate code.
Whatever the offending expression is, it should be avoided. You should notify
Borland International if the compiler ever encounters this error.
Register allocation failure
This is a sign of some form of compiler error. Some expression on the indicated line
of the source file was so complicated that the code generator could not generate
code for it. You should simplify the offending expression, and if this fails to solve the
problem, the expression should be avoided. Notify Borland International if the
compiler encounters this error.
4.2 Errors
#operator not followed by macro argument name
In a macro definition, the # may be used to indicate stringizing a macro argument.
The # must be followed by a macro argument name.
'XXXXXXXX' not an argument
Your source file declared the named identifier as a function argument but the
identifier was not in the function argument list.
Ambiguous symbol'XXXXXXXX'
The named structure field occurs in more than one structure with different offsets,
types, or both. The variable or expression used to refer to the field is not a structure
containing the field. Cast the structure to the correct type, or correct the field name
if it is wrong.
Argument # missing name
A parameter name has been left out in a function prototype used to define a
function. If the function is defined with a prototype, the prototype must include the
parameter names.
RVCE 11
12. Turbo C Compiler
Argument list syntax error
Arguments to a function call must be separated by spaces and closed with a right
parenthesis. Your source file contained an argument followed by a character other
than comma or right parenthesis.
Array bounds missing]
Your source file declared an array in which the array bounds were not terminated by
a right bracket.
Array size too large
The declared array would be too large to fit in the available memory of the
processor.
Assembler statement too long
In-line assembly statements may not be longer than 480 bytes.
Bad configuration file
The TURBOC.CFG file contains uncommented text that is not a proper command
option. Configuration file command options must begin with a dash (-).
4.3 Warnings
'XXXXXXXX' declared but never used
Your source file declared the named variable as part of the block just ending, but the
variable was never used. The warning is indicated when the the compiler encounters
the closing curly brace of the compound statement or function. The declaration of
the variable occurs at the beginning of the compound statement or function.
'XXXXXXXX' is assigned a value which is never used
The variable appears in an assignment, but is never used anywhere else in the
function just ending. The warning is indicated only when the compiler encounters
the closing curly brace.
'XXXXXXXX' not part of structure
The named field was not part of the structure on the left hand side of the dot (.) or
arrow (- », or else the left hand side was not a structure (for a dot) or pointer to
structure (for an arrow).
RVCE 12
13. Turbo C Compiler
Ambiguous operators need parentheses
This warning is displayed whenever two shift, relational or bitwiseboolean operators
are used together without parentheses. Also, an addition or subtraction operator
that appears unparenthesized with a shift operator will produce this warning.
Programmers frequently confuse the precedence of these operators, since the
precedence assigned to them is somewhat counter-intuitive.
Both return and return of a value used
This warning is issued when the compiler encounters a return statement that
disagrees with some previous return statement in the function. It is almost certainly
an error for a function to return a value in only some of the return statements.
Call to function with no prototype
This message is given if the "Prototypes required" warning is enabled and you call a
function without first giving a prototype for that function.
Call to function 'XXXX' with no prototype
This message is given if the "Prototypes required" warning is enabled and you call
function XXXX without first giving a prototype for that function.
RVCE 13
14. Turbo C Compiler
Chapter 5
Chapter 5
COMMAND-LINE OPTIONS
This appendix lists each of the Turbo C compile-time command-line options in alphabetical order
under option type, and describes what each option does. The options are broken down into three
general types:
1. compiler options
2. linker options
3. environment options
Within the compiler options, there are several categories of options; these specify
memory model
#defines (macro definitions)
code generation options
optimization options
source code options
error-reporting options
segment-naming control
To see an on-screen listing of all the TCC (command-line Turbo C) options, type tee Enter at the DOS
prompt (when you're in the TURBOC directory). Most of the command-line options have
counterparts in the Turbo C Integrated Development Environment (TC) Options menus (and a few
other menus). See Table C.l for a correlation of the TC menu selections and the TCC command-line
options.
5.1 Compiler Options
Turbo C's command-line compiler options can be broken down into eight logical groups. These
groups, and the ties that bind them, are as follows:
Memory model options allow you to specify under which memory model Turbo C will
compile your program. (The models range from Tiny to Huge.
RVCE 14
15. Turbo C Compiler
#defines (macro definitions) allow you to define macros (also known as manifest or symbolic
constants) to the default (which is 1), to a numeric value, or to a string; these options also
allow you to undefined previously-defined macros.
Code generation options govern characteristics of the generated code to be used at run-
time, such as the floating-point mode, calling convention, char type, or CPU instructions.
Optimization options allow you to specify how the object code is to be optimized; for size or
speed, with or without the use of register variables, and with or without redundant load
operations.
Source code options cause the compiler to recognize (or ignore) certain features of the
source code; implementation-specific (non-ANSI) keywords, nested comments, and
identifier lengths.
Error-reporting options allow you to tailor which warning messages the compiler will report,
and the maximum number of warnings (and errors) that can occur before the compilation
stops.
Segment-naming control allows you to rename segments and to reassign their groups and
classes.
Compilation control options allow you to direct the compiler to.
compile to assembly code (rather than to an object module.
compile a source file that contains in-line assembly.
compile without linking.
5.2 Linker Options
-efilename
Derives the executable program's name from filename by adding .EXE (the program' name
will then be 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.
-M
Forces the linker to produce a full link map. The default is to produce no link map.
RVCE 15
16. Turbo C Compiler
5.3 Environment Options
-Idirectory
Searches directory, the drive specifier or path name of a subdirectory, for include files (in
addition to searching the standard places). A drive specifier is a single letter, either
uppercase or lowercase, followed by a colon (:). A directory is any valid path name of a
directory file. Multiple -I directory options can be given.
-Ldirectory
Forces the linker to get the COx.OBJ start-up object file and the Turbo C library files (Cx.LIB,
MATHx.LIB, EMU.LIB, and FPB7.LIB) from the named directory. By default, the linker looks
for them in the current directory.
-nxxx
Places any .OBI or .ASM files created by the compiler in the directory or drive named by the
path xxx.
RVCE 16
17. Turbo C Compiler
BIBLIOGRAPHY
Turbo_C_Reference_Guide_1987 - IBM Version
http://www.wikipedia.com/BorlandTurboC
http://www.google.com/
RVCE 17