[ Previous | Next | Contents | Glossary | Home | Search ]
AIX Version 4.3 General Programming Concepts: Writing and Debugging Programs

Chapter 1. Tools and Utilities

Many tools are provided 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:

The following utilities 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 editors INed (or e) and vi. These editors display one full screen of data at a time and allow 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.
cflow Generates a diagram of the logic flow of a C language source program. The acronym cflow means C flow diagram generator.
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). The acronym cxref means C cross reference list.
cb Reformats a C language source program into a consistent format that uses indentation levels to show the structure of the program. The acronym cb means C beautifier.

Compiling and Linking a Program

The cc command compiles and links C language programs. See the cc command for more information about C For AIX.

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.

The compiler program changes the source statements into object code that the computer can run. The linkage editor connects program modules together and determines how to put the finished program into memory.

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. 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.

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. See "Subroutines Overview" 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.

AIX Support for the X/Open UNIX95 Specification

Beginning with AIX Version 4.2, the operating system is designed to support the X/Open UNIX95 Specification for portability of UNIX-based operating systems. Many new interfaces, and some current ones, have been added or enhanced to meet this specification. Beginning with Version 4.2, AIX is even more open and portable for applications.

At the same time, compatibility with previous AIX releases is preserved. This is accomplished by the creation of a new environment variable, which can be used to set the system environment on a per-system, per-user, or per-process basis.

The default AIX environment is one that maintains compatibility with previous AIX releases. To obtain an environment designed to conform to the UNIX95 specification, the environment variable XPG_SUS_ENV must be assigned the value ON. If XPG_SUS_ENV is set to any other value, or is unset, the default AIX behavior will be used.

When XPG_SUS_ENV is set, every program in that environment will operate in the UNIX95-specified operating system environment. It is possible that some applications compiled for the AIX environment (perhaps for an earlier version of AIX) will not operate correctly when XPG_SUS_ENV is set.

AIX 32-Bit and 64-Bit Support for the UNIX98 Specification

Beginning with AIX Version 4.3, the operating system is designed to support the X/Open UNIX98 Specification for portability of UNIX-based operating systems. Many new interfaces, and some current ones, have been added or enhanced to meet this specification. Making AIX Version 4.3 even more open and portable for applications.

At the same time, compatibility with previous AIX releases is preserved. This is accomplished by the creation of a new environment variable, which can be used to set the system environment on a per-system, per-user, or per-process basis.

Related Information

Manipulating Strings with sed.

m4 Macro Processor Overview.

Creating an Input Language with the lex and yacc Commands.

Message Facility Overview for Programming.

make Command Overview.

Subroutines Overview.


[ Previous | Next | Contents | Glossary | Home | Search ]