DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
C language compiler

Declarators

Declarators include:

What follows is a brief summary of the syntax of declarators:
   declarator:
   	pointer[opt] direct-declarator
   direct-declarator:
   	identifier
   	(declarator)
   	direct-declarator [constant-expression[opt]]
   	direct-declarator (parameter-type-list)
   	direct-declarator (identifier-list[opt])
   pointer:
   	* type-qualifier-list[opt]
   	* type-qualifier-list[opt] pointer

Pointer declarators

Array declarators

An array type of unknown size is known as an incomplete type.

Function declarators

Examples:

void srand(unsigned int seed);
The function srand returns nothing; it has a single parameter which is an unsigned int. The name seed goes out of scope at the ) and as such serves solely as documentation.

int rand(void);
The function rand returns an int; it has no parameters.

int strcmp(const char *, const char *);
The function strcmp returns an int; it has two parameters, both of which are pointers to character strings that strcmp does not change.

void (*signal(int, void (*)(int)))(int);
The function signal returns a pointer to a function that itself returns nothing and has an int parameter; the function signal has two parameters, the first of which has type int and the second has the same type as signal returns.

int fprintf(FILE *stream, const char *format, . . .);
The function fprintf returns an int; FILE is a typedef name declared in stdio.h; format is a const

note the use of ellipsis ( . . . ) to indicate an unknown number of arguments.


Next topic: Function definitions
Previous topic: Storage class specifiers

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003