Application Development Guide

Application Development Guide

Application Development Guide ~rogramming Family . ;. ~ Application Development Guide IBM Personal Cotnputer XENIXTM Software Developtnent Systetn Version 2.00 Programming Family ------..- - XENIX is a trademark of ---- - - --- Microsoft Corporation. - -. --- ----------.,-- - --- - Personal Computer Software Second Edition (April 1986) Changes are made periodically to the information herein; these changes will be incorporated in new editions of this publication. This edition applies to Version 2.00 of the XENIX Operating System, and to all subsequent releases until otherwise indicated in new editions or technical newsletters. References in this publication to IBM products, programs, or services do not imply that IBM intends to make these available in all countries in which IBM operates. Any reference to an IBM program product in this publication is not intended to state or imply that only IBM's program product may be used. Any functionally equivalent program may be used instead. International Business Machines Corporation provides this manual "as is," without warranty of any kind, either express or implied, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose. IBM may make improvements and/or changes in the product(s) and/or the program(s) described in this manual at any time. Products are not stocked at the address given below. Requests for copies of this product and for technical information about the system should be made to your authorized IBM Personal Computer dealer. A reader's comment form is provided at the back of this publication. If the form has been removed, address comments to IBM Corporation, Department 997, 11400 Burnet Road, Austin, Texas 78758. IBM may use or distribute whatever information you supply in any way it believes appropriate without incurring any obligation to you. Portions of the code and documentation described in this book were developed at the Electrical Engineering and Computer Sciences Department at the Berkeley Campus of the University of California under the auspices of the Regents of the University of California. Portions of the software and documentation are based on the Fourth Berkeley Distribution licensed from the Regents of the University of California. © Copyright International Business Machines Corporation 1985, 1986 © Portions copyright by Microsoft Corporation 1983, 1984, 1986, all rights reserved © Portions copyright by AT&T Bell Laboratories 1983, 1984, 1986, all rights reserved About This Book This guide is written for the application development programmer. It explains how to use the utility programs and routines available in the PC XENIX Software Development System. The programmer using this manual should be experienced with: • The IBM Personal Computer AT • The IBM Personal Computer XENIX • C language or another high-level programming language. For detailed formatting of command and option syntax, refer to IBM Personal Computer XENIX Commands Reference. Each chapter of this guide may be studied independently. After reading Chapter 1, use the table of contents to select the topic that interests you. The book is organized as follows: Chapter 1. Introduction Provides an overview of the PC XENIX Software Development System. Chapter 2. PC XENIX to DOS: A Cross Development System Provides information on creating programs that run under DOS. You can create, compile, and link DOS programs on PC XENIX and transfer them to a DOS system. Chapter 3. The lint Program: a C Language Program Checker Explains how to check C language programs for correct syntax and semantics. Chapter 4. A Program Maintainer: make Explains how to automate the development of a program or other proj ect. Chapter 5. SCCS: A Source Code Control System Explains how to control and maintain all versions of a proj ect's source files. Chapter 6. The adb Program Debugger Explains how to debug C and assembler language programs using the PC XENIX debugger adb. iii Chapter 7. The lex Program: A Lexical Analyzer Explains how to create lexical analyzers using the program generator lex. Chapter 8. The yacc Program Generator: A Compiler - Compiler Explains how to create parsers using the program generator yacc. Chapter 9. M4: A Macro Processor Explains how to create and process macros. Chapter 10. Writing Device Drivers Explains how to write device drivers for PC XENIX systems. Chapter 11. Sample Device Drivers Shows examples of device drivers with comments. Other PC XENIX Publications • IBM Personal Computer XENIX C Library Guide and Compiler Reference • IBM Personal Computer XENIX Commands Reference • IBM Personal Computer XENIX System Reference • IBM Personal Computer XENIX Macro Assembler Reference iv Application Development Guide Contents Chapter 1. Introduction ............... 1-1 Notational Conventions ...................... 1-1 Overview .................................. 1-2 Crea ting C Language Programs ................ 1-3 Creating Other Programs ..................... 1-4 Creating and Maintaining Libraries ............. 1-5 Maintaining Program Source Files .............. 1-5 Creating Programs with Shell Commands ......... 1-7 Chapter 2. PC XENIX to DOS: A Cross-Development System ............ 2-1 Introduction ............................... 2-1 Creating DOS Source Files .................... 2-2 Compiling a DOS Source File .................. 2-3 U sing Assembler Language Source Files .......... 2-4 Linking DOS Object Files ..................... 2-5 Running and Debugging a DOS Program ......... 2-5 Transferring Programs between Systems .......... 2-6 Creating DOS Libraries ....................... 2-7 Chapter 3. The lint Program - a C Program Checker ........................... 3-1 Introduction ............................... 3-1 Invoking lint ............................... 3-2 Checking for Unused Variables and Functions ..... 3-3 Checking Local Variables ..................... 3-4 Checking for Unreachable Statements ........... 3-5 Checking Function Return Values .............. 3-6 Checking for Unused Return Values ............. 3-7 Checking Types ............................. 3-7 Checking Type Casts ......................... 3-9 Checking for Nonportable Characters ........... 3-10 Checking for Assignment of longs to ints ........ 3-11 Checking for Strange Constructions ............ 3-12 Checking Pointer Alignment .................. 3-14 Contents v Checking for Older C Syntax ................. 3-14 Checking Expression Evaluation Order .......... 3-16 Embedding Directives ....................... 3-17 Checking for Library Compatibility ............ 3-18 Chapter 4. A Program Maintainer: make 4-1 Introduction ............................... 4-1 Creating a Makefile ......................... 4-2 Invoking make ............................. 4-4 Using Pseudo-Target Names ................... 4-6 Using Macros .............................. 4-7 Using Shell Environment Variables ............ 4-11 Using Built-In Rules ........................ 4-13 Changing Built-In Rules ..................... 4-15 Using Libraries ............................ 4-18 Troubleshooting ........................... 4-20 An Example: Using make .................... 4-21 Chapter 5. SCCS: A Source Code Control System ............. .-'. .. 5-1 Introduction ............................... 5-1 Basic Information ........................... 5-2 Creating and Using s-files ..................... 5-7 Using Identification Keywords ................ 5-18 Using s-file Flags .......................... 5-20 Modifying s-file Information .................. 5-23 Printing from an s-file ....................... 5-28 Editing by Several Users ..................... 5-30 Protecting s-files ........................... 5-32 Repairing SCCS Files ....................... 5-35 Using other Command Options ................ 5-36 Chapter 6. The adb Program Debugger .... 6-1 Introduction ............................... 6-1 Starting and Stopping adb ..................... 6-1 Displaying Instructions and Data ............... 6-6 Debugging Program Execution ................ 6-20 Using the adb Memory Maps .................. 6-34 Validating Addresses ........................ 6-37 Miscellaneous Features ...................... 6-38 An Example: Directory and Inode Dumps ........ 6-44 Patching Binary Files ....................... 6-46 vi Application Development Guide Chapter 7. The lex Program: A Lexical Analyzer .......................... 7-1 Introduction ............................... 7-1 Invoking lex ....................,0.......... 7-4 The lex Source Format ....................... 7-5 The lex Regular Expressions ................... 7-7 Using the Operator Characters ................. 7-8 Writing Actions ........................... 7-14 Handling Ambiguous Source Rules ............. 7-19 Specifying Left Context Sensitivity ............. 7-23 Specifying Source Definitions ................. 7-26 Using yacc with lex ......................... 7-28 Specifying Character Sets .................... 7-29 Source Format . .. 7-31 A lex Example ............................. 7-34 Chapter 8. The yacc Program Generator: A Compiler-Compiler ................... 8-1 Introduction ............................... 8-1 Specifications .............................. 8-5 Actions ................................... 8-9 Lexical Analysis ........................... 8-12 How the Parser Works ...................... 8-14 Ambiguity and Conflicts ..................... 8-21 Precedence ............................... 8-27 Error Handling ............................ 8-31 The yacc

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    444 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us