• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Turbo C Compiler Reports
 

Turbo C Compiler Reports

on

  • 1,800 views

 

Statistics

Views

Total Views
1,800
Views on SlideShare
1,800
Embed Views
0

Actions

Likes
0
Downloads
25
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Turbo C Compiler Reports Turbo C Compiler Reports Document Transcript

    • Turbo C CompilerChapter 1 INTRODUCTION1.1 Overview of BackgroundIn the early 1980s, Borland enjoyed considerable success with their Turbo Pascal productand 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 forprofessional 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, largeproject support and price. It is developed in C.RVCE 1
    • Turbo C CompilerChapter 2Chapter 2 BORLAND TURBO CTurbo C is an Integrated Development Environment and a compiler for the C programminglanguage from Borland. First introduced in 1987, it was noted for its integrateddevelopment environment, small size, fast compile speed, comprehensive manuals and lowprice.In May 1990, Borland replaced Turbo C with Turbo C++. In 2006, Borland reintroduced theTurbo 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++ compilerwas developed under contract by a company in San Diego and was one of the first truecompilers for C++ (until then, most C++ work was done with pre-compilers that generated Ccode). The next version was named Borland C++ to emphasize its flagship status andcompletely rewritten in-house, with Peter Kukol as the lead engineer. The Turbo C++ namewas briefly dropped, eventually reappearing as Turbo C++ 3.0. There was never a 2.0 of theTurbo C++ product series.Borland split the product (and later Pascal) in two lines, one for beginners and one forprofessionals. 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 ofTurbo C++ 3.0 and Borland C++ 5.0. As with Turbo Pascal, there was also a Turbo C++ forMicrosoft windows, which reached version 4.5.Turbo C for the Atari ST ended with version 2.0. The program was not maintained byBorland, but the product was sold and renamed PureC.From 1996, Delphi became Borlands principle and highly successful Pascal toolkit. A similarrelease based on C++ became Borland C++Builder, which replaced Borland C++.RVCE 2
    • Turbo C Compiler2.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.0Released on May 13, 1987, offered the first integrated edit-compile-run developmentenvironment 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 byBob Jervis (Borlands flagship product at that time, Turbo Pascal, which at this time did nothave pull-down menus, would be given a facelift with version 4 released late in 1987 tomake it look more like Turbo C.) It ran in 384 kB of memory. It allowed inline assembly withfull access to C symbolic names and structures, supported all memory models, and offeredoptimizations for speed, size, constant folding, and jump elimination. Version 1.5in January 1988 was an incremental improvement over version 1.0. It included more sampleprograms, improved manuals and bug fixes. It was shipped on five 360 KB diskettes ofuncompressed files, and came with sample C programs, including a stripped downspreadsheet called mcalc. This version introduced the <conio.h> header file (which providedfast, PC-specific console I/O routines. Version 2.0In 1989 was released was in late 1988, and featured the first "blue screen" version, whichwould be typical of all future Borland releases for MS-DOS. The American release did notRVCE 3
    • Turbo C Compilerhave Turbo Assembler or a separate debugger. (These were sold separately as TurboAssembler.) Turbo C, Asm, and Debugger were sold together as a suite. This seems todescribe another release: Featured Turbo Debugger, Turbo Assembler, and an extensivegraphics library. This version of Turbo C was also released for the Atari ST, but distributedin Germany only.2.2 Turbo C Library RoutinesTurbo C comes equipped with over 300 library routines-functions and macros that you callfrom 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 Cs routines are contained in the library files (Cx.LIB and MATHx.LIB). Because Turbo Csupports 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 functionprototypes to be given for the routines in your C programs. All of Turbo Cs library routinesare declared with prototypes in one or more header file (these are the .H or "include" filesthat 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
    • Turbo C Compiler2.4 Language Syntax SummaryThis appendix uses a modified Backus-Naur Form to summarize the syntax for Turbo Cconstructs. 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 directives2.5 Customizing Turbo CTurbo C comes ready to run, as soon as you make working copies of the disk files. There isno installation, per se. But you do have the option of changing many of Turbo Cs defaultmodes of operation by running this customization program. This program, TCINST.COM, letsyou 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 Cs windowsIf you want to store your help (TCHELP.TCH) or configuration files (TCCONFIG.TC) in adirectory other than the one where you do your work, youll need to use the Turbo Cdirectory option to set a path to those files.If youre either unfamiliar with Turbo Cs editor or inexorably tied to another editor, you canuse the Editor commands option to reconfigure (customize) the editor keystrokes to yourliking.You can also use the Default editor mode option to set several defaults for the editor. Youcan choose toRVCE 5
    • 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 offYou can set up the display mode that Turbo C will use when it is in operation and specifywhether you have a "snowy" video adapter. You can customize the colors of almost everypart of the Turbo C screen output. And finally, you can change the default sizes of the Editand Message windows.RVCE 6
    • Turbo C CompilerChapter 3 TURBO C INTERACTIVE EDITORTurbo Cs built-in editor is specifically designed for creating program source text. If you arefamiliar with the Turbo Pascal or SideKick editor, or MicroPros WordStar program, youalready know how to use the Turbo C editor, since its commands are almost identical to oneof these editors. A section at the end of this appendix summarizes the few differencesbetween Turbo Cs editor commands and WordStars commands. The Turbo C editor, unlikeWordStar, has a "restore" facility that lets you take back changes if you havent yet left theline. This command (Ctrl-Q L) is described in "Miscellaneous Editing Commands."Quick In, Quick OutTo invoke the editor, choose Edit from Turbo Cs main menu. The Edit window becomes the"active" window; the Edit windows title is highlighted and the cursor is positioned in theEdit window. To enter text, type as though you were using a typewriter. To end a line, pressthe Enter key. To invoke the main menu from within the editor, press F10 (the data in theEdit window remains on screen).3.1 Editor CommandsThe 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 maincategories:  cursor movement commands (basic and extended)  insert and delete commands  block commands  miscellaneous commandsRVCE 7
    • Turbo C Compiler3.2 The Turbo C Editor Vs. WordStarA few of the Turbo C editors commands are slightly different from WordStar. Also, althoughthe Turbo C editor contains only a subset of WordStars commands, several features notfound in WordStar have been added to enhance program source-code editing. Thesedifferences are discussed here, in alphabetical order.AutoindentThe Turbo C editors 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. (Ifyou press Enter at the end of a line when Insert mode is off, the editor will not insert acarriage return character or move the cursor to the next line.) To enter carriage returns, youcan either switch to Insert mode or use Ctr/-N in Overwrite mode.Cursor movementTurbo Cs cursor movement controls-Ctr/-S, Ctr/-O, Ctr/-E, and Ctr/X- move freely around onthe screen without jumping to column one on empty lines. This does not mean that thescreen is full of blanks, on the contrary, all trailing blanks are automatically removed. Thisway of moving the cursor is especially useful for program editing, for example, whenmatching indented statements.Delete to leftThe WordStar sequence Ctr/-Q Oe/, delete from cursor position to beginning of line, is notsupported.Mark word as blockTurbo C allows you to mark a single word as a block using Ctr/-K T. This is more convenientthan WordStars two-step process of separately marking the beginning and the end of theword.RVCE 8
    • Turbo C CompilerMovement across line breaksCtr/-S and Ctr/-O do not work across line breaks. To move from one line to another youmust use Ctr/-E, Ctr/-X, Ctr/-A, or Ctr/-F.Quit editTurbo Cs Ctr/-K Q does not resemble WordStars 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.UndoTurbo Cs Ctr/-Q L command restores a line to its pre-edit contents as long as the cursor hasnot left the line.RVCE 9
    • Turbo C CompilerChapter 44 Chapter COMPILER ERROR MESSAGESThe 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 erroroccurs, compilation immediately stops. You must take appropriate action and then restartcompilation. Errors indicate program syntax errors, disk or memory access errors, andcommand line errors. The compiler will complete the current phase of the compilation andthen stop. The compiler attempts to find as many real errors in the source program aspossible during each phase (preprocessing, parsing, optimizing and code-generating).Warnings do not prevent the compilation from finishing. They indicate conditions which aresuspicious, but which are legitimate as part of the language. Also, the compiler will producewarnings if you use machinedependent constructs in your source files. The compiler printsmessages with the message class first, then the source file name and line number where thecompiler detected the condition, and finally the text of the message itself. In the followinglists, messages are presented alphabetically within message class. With each message, aprobable cause and remedy are provided. You should be aware of one detail about linenumbers 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 truecause of the error may be one or more lines before the line number mentioned. In thefollowing message list, we have indicated those messages which often appear (to thecompiler) 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
    • 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 symbolXXXXXXXX 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
    • 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
    • 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
    • Turbo C Compiler Chapter 5Chapter 5 COMMAND-LINE OPTIONSThis appendix lists each of the Turbo C compile-time command-line options in alphabetical orderunder option type, and describes what each option does. The options are broken down into threegeneral types: 1. compiler options 2. linker options 3. environment optionsWithin 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 controlTo see an on-screen listing of all the TCC (command-line Turbo C) options, type tee Enter at the DOSprompt (when youre in the TURBOC directory). Most of the command-line options havecounterparts in the Turbo C Integrated Development Environment (TC) Options menus (and a fewother menus). See Table C.l for a correlation of the TC menu selections and the TCC command-lineoptions.5.1 Compiler OptionsTurbo Cs command-line compiler options can be broken down into eight logical groups. Thesegroups, 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
    • 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 programs 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 files 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
    • Turbo C Compiler5.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
    • Turbo C Compiler BIBLIOGRAPHY  Turbo_C_Reference_Guide_1987 - IBM Version  http://www.wikipedia.com/BorlandTurboC  http://www.google.com/RVCE 17