next up previous contents
Next: 3 Primitive Data Structures Up: 2 Compiling And Running Previous: 2.5 Debugging information

2.6 Enabling one-pass linking

The g++ compilers perform linking in one pass. This puts some restrictions on the structure of the library being linked. Namely, it should be possible to topologically sort all the library object files according to the call graph. This restriction doesn't apply to the virtual functions, which are always linked in. Unfortunately, the logical structure of the Omega library does not allow to us distribute functions among the files in a such a way that this restriction holds. To resolve this problem, we force some functions to be always linked into the executable (just as the virtual functions are always linked in.) This is implemented in the lib_hack.c file, whose only purpose is to enable this trick. The target check_order in the makefile allows you to check that a correct ordering of functions in the library exists (accounting for the functions that are always linked). You never need to do this if you only use the functions the library provides; only users who extend the library should ever need to check this.