6.1.21. UNION and MAP

6.1.21 UNION and MAP

Unions are an old vendor extension which were commonly used with the non-standard STRUCTURE and RECORD extensions. Use of UNION and MAP is automatically enabled with -fdec-structure.

A UNION declaration occurs within a structure; within the definition of each union is a number of MAP blocks. Each MAP shares storage with its sibling maps (in the same union), and the size of the union is the size of the largest map within it, just as with unions in C. The major difference is that component references do not indicate which union or map the component is in (the compiler gets to figure that out).

Here is a small example:

structure /myunion/
union
  map
    character(2) w0, w1, w2
  end map
  map