[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]

General Programming Concepts: Writing and Debugging Programs


Chapter 1. Tools and Utilities

The AIX Operating System provides many tools to help you develop C language programs. To access these tools, you enter a command on the command line. The tools provide help in the following programming areas:

Subroutines and Shell Commands are provided for use in a C language program.


Entering a Program into the System

The system has a line editor called ed for use in entering a program into a file. The system also has the full-screen editor called vi, which displays one full screen of data at a time and allows interactive editing of a file.


Checking a Program

The following commands allow you to check the format of a program for consistency and accuracy:

lint Checks for syntax and data type errors in a C language source program. The lint command checks these areas of a program more carefully than the C language compiler does, and displays many messages that point out possible problems.
cb Reformats a C language source program into a consistent format that uses indentation levels to show the structure of the program.
cflow Generates a diagram of the logic flow of a C language source program.
cxref Generates a list of all external references for each module of a C language source program, including where the reference is resolved (if it is resolved in the program).

Compiling and Linking a Program

To make source code into a program that the system can run, you need to process the source file with a compiler program and a linkage editor.

A compiler is a program that reads program text from a file and changes the programming language in that file to a form that the system understands. The linkage editor connects program modules together and determines how to put the finished program into memory. To create this final form of the program, the system does the following:

Other programming languages available for use on the operating system include the FORTRAN, Pascal, and Assembler languages. Refer to documentation on these programming languages for information on compiling and linking programs written in them.

You can write parts of a program in different languages and have one main routine call and start the separate routines to execute, or use the cc program to both assemble and link the program.

Correcting Errors in a Program

The following debugging tools are available for use:

When syntax errors or parameter naming inconsistencies are discovered in a program file, a text editor or string-searching and string-editing programs can be used to locate and change strings in the file. String-searching and string-editing programs include the grep, sed, and awk commands. To make many changes in one or more program files, you can include the commands in a shell program and then run the shell program to locate and change the code in the files.

Building and Maintaining a Program

Two facilities are provided to help you control program changes and build a program from many source modules. These commands can be particularly useful in software development environments in which many source modules are produced.

The make command builds a program from source modules. Since the make command compiles only those modules changed since the last build, its use can reduce compilation time when many source modules must be processed.

Chapter 23, Source Code Control System (SCCS) allows you to maintain separate versions of a program without storing separate, complete copies of each version. The use of SCCS can reduce storage requirements and help in tracking the development of a project that requires keeping many versions of large programs.


Subroutines

Subroutines from system libraries handle many complex or repetitive programming situations so that you can concentrate on unique programming situations. See Subroutines Overview (Chapter 24, Subroutines, Example Programs, and Libraries) for information on using subroutines and for lists of many of the subroutines available on the system.


Shell Commands

You can include the functions of many of the shell commands in a C language program. Any shell command used in a program must be available on all systems that use the program.

You can then use the fork and exec subroutines in a program to run the command as a process in a part of the system that is separate from the program. The system subroutine also runs a shell command in a program, and the popen subroutine uses shell filters.

Related Information

Manipulating Strings with sed

Chapter 15, m4 Macro Processor Overview

Creating an Input Language with the lex and yacc Commands

Message Facility Overview for Programming

Chapter 14, make Command

Chapter 24, Subroutines, Example Programs, and Libraries


[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]