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++ only 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 diagram
Function declaration syntax

>>-+-------------------------+--+--------------------+---------->
   '-storage_class_specifier-'  '-function_specifier-'   

>--return_type_specifier--function_declarator--;---------------><

C++11
Note: When function_declarator incorporates a trailing return type, return_type_specifer must be auto. For more information about trailing return type, see Trailing return type (C++11).
C++11

IBM extension In addition, for compatibility with GNU C and C++, XL C/C++ allows you to use attributes to modify the properties of functions. They are described in Function attributes (IBM extension).