Node:attribute, Next:begin, Previous:Assigned, Up:Reference

### attribute

(Under construction.)

#### Synopsis

    declaration attribute (name);

or

    declaration attribute (name = parameter);

or

    declaration attribute (name (parameter, parameter ...));

#### Description

Several attributes can be given in one `attribute` directive, separated with `,`, or in several `attribute` directives.

Besides the attributes that GCC supports (see Attribute Syntax), GPC allows the following attributes for variables:

- static
- register
- volatile
- const
- external
- name (with a string constant parameter)

For routines it allows the following additional attributes:

- ignorable
- inline
- iocritical
- name (with a string constant parameter)

For types it allows the following additional attributes:

- iocritical (for procedural [pointer] types)
- size (with an integer constant parameter)

`Size` can be applied to integer and Boolean types to produce types with a specified size in bits; for example

    type
      Card16 = Cardinal attribute (Size = 16);

defines an unsigned integer type with 16 bits.

Variable and routine attributes are preceded by a `;`, type attributes are not. So, e.g., in the following example, the `Size` attribute applies to the type, and the `static` attribute to the variable.

    var a: Integer attribute (Size = 64); attribute (static);

#### Conforming to

`attribute` is a GNU Pascal extension.

#### Example

    program AttributeDemo;

    { Demo for `iocritical' attribute. }

    { Program will abort with a runtime error! }

    {$I-}
    procedure p; attribute (iocritical);
    var t: Text;
    begin
      Reset (t)  { Will not cause a runtime error here because I/O
                   checking is off, but leave InOutRes set. }
    end;
    {$I+}

    begin

      p;
      { Since `p' was declared `iocritical', and I/O checking is now on,
        InOutRes is checked immediately after the call to p, and a
        runtime error raised. }

      { So this statement is never reached. }
      InOutRes := 0;

      { Neither this one, which would be reached without the
        `iocritical' attribute. }
      WriteLn ('never gets here')

    end.

#### See also

Keywords, external.