Lugaru's Epsilon
Programmer's
Editor 14.04

Context:
Epsilon User's Manual and Reference
   Epsilon Extension Language
      . . .
      Scope of Variables
      Data Types
         . . .
         Simple Declarators
         Pointer Declarators
         Array Declarators
         Function Declarators
         Structures and Unions
         . . .
      Initialization
      . . .

Previous   Up    Next
Pointer Declarators  Epsilon Extension Language   Function Declarators


Epsilon User's Manual and Reference > Epsilon Extension Language > Data Types >

Array Declarators

Array declarators are used in conjunction with type specifiers to declare objects of type array of t, where t is some type. The form of an array declarator is

declarator [ constant-expression ]

but you may omit the constant expression if

  • An initialized global variable of type "array of ..." is being defined. (See Initialization.) In this case, the first constant-expression may be omitted, and the size of the array will be calculated from the initializer.

  • A function argument (sometimes called a formal parameter) of type "array of ..." is being declared. Since the type of the argument will be changed to "pointer to ..." (as described in Function Definitions) the first constant-expression may be omitted.

The rules for constant expressions appear in Constant Expressions.

Suppose T is a type specifier and D is a declarator, and the declaration "T D;" declares the identifier embedded in D to be of type "... T". Then the declaration T (D)[ ]; declares the identifier to be of type "... array of T".

As an example, consider:

int (one_dim)[35];
int ((two_dim)[35])[44];

The first line declares the identifier one_dim to be of type array of int.

The second line declares two_dim to be array of array of int. Clearly, we can have arbitrary multi-dimensional arrays by declaring the arrays in this manner.

As another example, consider the following:

char (*arg);
char (*argptr)[5];
char *(argary[5]);

From the preceding section, we know that the first line declares arg to be a pointer to a char. From this section, we see that the second line declares argptr to be of type pointer to array of char.

Compare this to the third line, which declares argary to be of type array of pointer to char.

When you have mixed declarators as you have in this example, you sometimes can elide parentheses according to the precedence rules of declarators. See Complex Declarators for these precedences.



Previous   Up    Next
Pointer Declarators  Epsilon Extension Language   Function Declarators


Lugaru Epsilon Programmer's Editor 14.04 manual. Copyright (C) 1984, 2021 by Lugaru Software Ltd. All rights reserved.