A function may be defined with the
“static
” prefix. When a function is declared as
static, it can only be invoked from the file in which it is defined. This
mechanism can be seen as a primitive form of restricting the access to a
function, although it is still far from the three level mechanism (private,
public, protected) present in Java.
During the development of large applications, a policy is typically enforced with respect to the use of prototypes. For example, to allow the use of any function in a file anywhere in that file, the prototypes of all the functions are placed at the top of the file. The following example shows an example of this policy:
1 2 3 4 5 6 7 8 9 10 | /* Global functions */ int function1(int p1, float p2, int table[], int size); void function2(); struct data *function3(char *name, char* lastname, int status); /* Local functions */ static void check(int table[], int size); static struct data *duplicate(struct data *d1); /* Definitions */ .... |