HP-UX HB v13.00 Ch-11 - Software Development

HP-UX Handbook Rev 13.00 Page 5 (of 101)
Chapter 11 Software Development
October 29, 2013
By default, the front-ends will execute all necessary build steps to create an executable from the
input files passed to it. In the simplest case the build command to create a program from a source
file is:
<frontend command> -o <program name> <source file>
To execute only one step of the build process, additional arguments must be passed to the
frontend. Which options are available and much other information about the frontend and the
compiler itself can be found in the appropriate frontend manpages which are installed with the
compiler product.
Source Code
This page is intended to give a somewhat simplified view over the structure of programs and its
sources. The things discussed will be demonstrated with little pieces of ANSI C code, which
hopefully can be understood even without programming knowhow.
Program Structure
Programs are organized in functions. A function is (as you might remember from your math
classes) a construct that takes one or more operands, and returns a result. In a program functions
are also referenced to as procedures, subroutines or methods, the operands are called arguments
or parameters, and the result is usually called the return value. The function body contains the
instructions that process the arguments to generate the return value. Often the major task of a
function is to process the arguments rather than generating a return value. The instructions can
also contain calls to other functions to execute subtasks.
A program is intended to process data, so besides functions it also needs means to store data. A
piece of data is called a variable.
Functions and variables are often abstractly called symbols. Symbols are only distinguished by
name. We decide between global and local symbols. As the name implies, global symbols can be
accessed in the whole program, while local symbols are only available within a certain area of
the program. This access range is called the scope of the variable.
Programmatical Conventions
In a program source you typically will find declarations and definitions for symbols. A
declaration is used to specify names and types of functions, function arguments, return values
and variables. It determines how to use a symbol so it can be referenced, but it doesn't create it.
int main();