English
Language : 

CC78K4 Datasheet, PDF (134/523 Pages) NEC – CC78K4 Ver.2.30 or Later, C Compiler Language
CHAPTER 8 EXTERNAL DEFINITIONS
8.1 Function Definition
A function definition is an external definition that begins with a declaration of the function. If the storage class
specifier is omitted from the declaration, extern is assumed to have been defined. An external function definition
means that the defined function may be referenced from other files. For example, in a program consisting of two or
more files, if a function in another file is to be referenced, this function must be defined externally.
The storage class specifier of an external function is extern or static. If a function is declared as extern, the
function can be referenced from another file. If declared as static, it cannot be referenced from another file.
In the following example, the storage class specifier is “extern” and the type specifier is “int”. These two are
default values and thus may be omitted from specification. The function declarator is “max(int a, int b)” and the body
of the function is “{return a>b?a:b;)”.
[Example of function definition]
extern int max(int a, int b)
{
return a>b?a :b ;
}
Because this function definition specifies a parameter type in the function declaration, the type of argument is
forcibly converted by the compiler. This type conversion can be described by using the form of an identifier list for
the parameters. An example of this identifier list is shown below.
extern int max(a, b)
int a, b;
{
return a>b?a:b;
}
The address of a function may be passed as an argument to the function call. By using the function name in the
expression, a pointer to the function can be generated.
int f(void);
void main( ){
:
g(f);
}
134
User’s Manual U15556EJ1V0UM