[ First ] [ Previous ] [ Next ] [ Last ] [ Manuals ]
Correcting Pascal Circular References

The CodeWarrior Pascal compiler's Make and Run commands build your project by examining every Pascal file in your project file. As this examination is performed, a tree of dependencies is built for the interfaces of your units and for their implementations.
A circular reference occurs when a unit declares something that is used in another unit and that same unit declares something used by the former. To break this loop, the Pascal compiler does not allow such things among the interface parts of units, but it is permitted for implementations.
The example in Listing 10.1 is perfectly valid, since both A's and B's interfaces depend on C's, but are independent from one another. Knowing everything that was declared, A's implementation depends on all interfaces, the same is true for B's and C's. For this example, the make utility will ask the compiler to compile Listing 10.1 in the following order:
A valid example of circular referencing:
UNIT A; UNIT B; UNIT C;
INTERFACE INTERFACE INTERFACE
USES C; USES C;
TYPE TYPE TYPE
A_type = ... B_type = .... C_type = ...
IMPLEMENTATION IMPLEMENTATION IMPLEMENTATION
USES B; USES A; USES A, B;
.... ... ...
1. C's interface is compiled.
2. B's interface is compiled.
3. All of unit A is compiled (unit and implementation),
4. B's implementation is compiled.
5. C's implementation is compiled.
After an interface compilation, the compiler writes a binary symbol table, containing all the declarations of the interface, in an 'sbmf' resource in the project file. This information is read back when the unit's name is encountered in a USES clause for another compilation. A unit is recompiled only when one of the following conditions occur:
[ First ] [ Previous ] [ Next ] [ Last ] [ Manuals ]
Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: cw_support@metrowerks.com
Copyright © 2000, Metrowerks Corp. All rights reserved.
Last updated: August 17, 2000