Compartir a través de


Argument Lists in Function Prototypes (Nondefining Declaration)

The form argument-declaration-list is a list of the type names of the arguments. Consider an argument-declaration-list for a function, func, that takes these three arguments: pointer to type char *, char, and int.

The code for such an argument-declaration-list can be written:

char *, char, int

The function declaration (the prototype) might therefore be written:

void func( char *, char, int );

Although the preceding declaration contains enough information for the compiler to perform type checking and conversions, it does not provide much information about what the arguments are. A good way to document function declarations is to include identifiers as they would appear in the function definition, as in the following:

void func( char *szTarget, char chSearchChar, int nStartAt );

These identifiers in prototypes are useful only for default arguments, because they go out of scope immediately. However, they provide meaningful program documentation.

See Also

Concepts

Function Declarations