HP C A.06.05 Reference Manual
Data Types and Declarations
Function Definitions
Chapter 370
Function Definitions
A function definition introduces a new function.
Syntax
function-definition
::=
[declaration-specifiers] declarator [declaration-list] compound-statement
Description
A function definition provides the following information about the function:
1. Type.
You can specify the return type of the function. If no type is provided, the default return
type is int. If the function does not return a value, it can be defined as having a return
type of void. You can declare functions as returning any type except a function or an
array. You can, however, define functions that return pointers to functions or pointers to
arrays.
2. Formal parameters. There are two ways of specifying the type and number of the formal
parameters to the function:
a. A function declarator containing an identifier list.
The identifiers are formal parameters to the function. You must include at least one
declarator for each declaration in the declaration list of the function. These
declarators declare only identifiers from the identifier list of parameters. If a
parameter in the identifier list has no matching declaration in the declaration list, the
type of the parameter defaults to int.
b. A function declarator containing a parameter type list (prototype form).
In this case, the function definition cannot include a declaration list. You must include
an identifier in each parameter declaration (not an abstract declarator). The one
exception is when the parameter list consists of a single parameter of type void; in
this case do not use an identifier.
NOTE Function prototypes can be used only in ANSI mode.