HPlogo HP C/HP-UX Reference Manual: Version A.05.55.02 > Chapter 3 Data Types and Declarations

Type Names

» 

Technical documentation

Complete book in PDF

 » Table of Contents

 » Index

A type name is syntactically a declaration of an object or a function of a given type that omits the identifier. Type names are often used in cast expressions and as operands of the sizeof operator.

Syntax

type-name ::=
specifier-qualifier-list [abstract-declarator]

abstract-declarator ::=
pointer
[pointer] direct-abstract-declarator

direct-abstract-declarator
( abstract-declarator )
[direct-abstract-declarator] [ [constant-expression] ]
[direct-abstract-declarator] ( [parameter-type-list] )

Description

Type names are enclosed in parentheses to indicate a cast operation. The destination type is the type named in the cast; the operand is then converted to that type. A type name is a declaration without the identifier specified. For example, the declaration for an integer is int i. If the identifier is omitted, only the integer type int remains.

Examples

int             int
int *           Pointer to int
int ()          Function returning an int
int *()         Function returning a pointer to int
int (*)()       Pointer to function returning an int
int [3];        Array of 3 int
int *[3];       Array of 3 pointers to int
int (*)[3];      Pointer to an array of 3 int

The parentheses are necessary to alter the binding order in the cases of pointer to function and pointer to array. This is because function and array declarators have higher precedence than the pointer declarator.

© Hewlett-Packard Development Company, L.P.