Tools and utilities

This section provides an overview of the tools and utilities that you can use to develop C compiled language programs.

Many tools are provided to help you develop C compiled programs. The tools provide help with the following programming tasks:

Subroutines and shell commands are provided for use in a C compiled 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

Use the following commands to check the format of a program for consistency and accuracy:

Commands Description
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).
lint Checks for syntax and data type errors in a C language source program. The lint command might check these areas of a program more carefully than the C language compiler does, and displays many messages that point out possible problems.

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

A compiler is a program that reads 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 and determines how to put the finished program into memory. To create this final form of the program, the system does the following:

  1. If a file contains compiler source code, the compiler translates it into object code.
  2. If a file contains assembler language, the assembler translates it into object code.
  3. The linkage editor links the object files created in the previous step with any other object files specified in the compiler command.

Other programming languages available for use on the operating system include the C++, FORTRAN, COBOL, and Assembler and other compiler languages.

You can write parts of a program in different languages and have one main routine call and start the separate routines to execute. You can also use the compiler program to create object code and link the program.

Correcting errors in a program

You can use the following debugging tools that are provided with the base operating system:

  • The dbx symbolic debug program allows you to debug programs written in C language, C++, FORTRAN, COBOL and Assembler languages.
  • The adb debug program provides subcommands you can use to examine, debug, and repair executable binary files and to examine non-ASCII data files.
  • KDB Kernel Debugger and kdb command can help you determine errors in code running in the kernel. You can use this debug program to debug device drivers and kernel extensions.
  • The trace facility helps isolate system problems by monitoring selected system events.

When syntax errors or parameter-naming inconsistencies are discovered in a program file, you can use a text editor or string-searching and string-editing programs 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

The following facilities help you control program changes and build a program from many source modules. These facilities can be particularly useful in software development environments in which many source modules are produced.
  • The make command builds a program from source modules. Because 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.
  • The 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.

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.