next up previous contents index
Next: Obsolete and Deprecated Features Up: BLOCK DATA Program Units Previous: BLOCK DATA Program Units

Linking Block Data Program Units

If, when linking a program, one of the modules containing a procedure is accidentally omitted the linker is almost certain to produce an error message. But, unless additional precautions are taken, this will not occur if a block data subprogram unit is omitted. The program may even appear to work without it, but is likely to produce the wrong answer.

There is a simple way to guard against this possibility: the name of the block data unit should be specified in an EXTERNAL statement in at least some of the program units in which the common block is used. There is no harm in declaring it in all of them. This ensures that a link-time reference will be generated if any of these other program units are used. There is a slight snag to this technique if an INCLUDE statement is used to bring the common block definition into each program unit including the block data unit. In order to avoid a self-reference, the include-file should not contain the EXTERNAL statement.

Despite this slight complication, this is a simple and valuable precaution. It also makes is possible to hold block data units on object libraries and retrieve them automatically when they are required, just like all other types of subprogram unit.



Mario Storti
Wed Nov 4 19:32:56 ART 1998