Function declarations

A function identifier preceded by its return type and followed by its parameter list is called a function declaration or function prototype. The prototype informs the compiler of the format and existence of a function prior to its use. The compiler checks for mismatches between the parameters of a function call and those in the function declaration. The compiler also uses the declaration for argument type checking and argument conversions.

C++ Implicit declaration of functions is not allowed: you must explicitly declare every function before you can call it.

C only If a function declaration is not visible at the point at which a call to the function is made, the compiler assumes an implicit declaration of extern int func(); However, for conformance to C99, you should explicitly prototype every function before making a call to it.

The elements of a declaration for a function are as follows:

All function declarations have the form:

Read syntax diagramSkip visual syntax diagramFunction declaration syntax
 
>>-+---------------------------------------------+-------------->
   '-storage_class_specifier--function_specifier-'
 
>--return_type_specifier--function_declarator--;---------------><
 

IBM extension In addition, for compatibility with C++, you can use attributes to modify the properties of functions. They are described in Function attributes.



[ Top of Page | Previous Page | Next Page | Contents | Index ]