Sessions on advanced C++ programming
Half-day seminar at CCC
Author: Zoltán Porkoláb
Budapest, 2007
A.7. Compiling and linking issues
Topics
- Compile-time dependences in C++
Object-orientation is a well-accepted technology to minimalize
object interactions, ie: run-time dependences between objects.
In the same time reducing compile-time dependences is
also an important issue for project management purposes.
- Compilation firewalls
Compile-time dependences could be minimalized using the
PIMPL idiom, which is often called Compile-time
firewalls. We discuss here the different options.
- Fast PIMPL idiom
PIMPL has some disadvantages, here we discuss them, and also
see an alternative solution, the fast PIMPL idiom.
- Codeblow
Using templates sometimes cause exponential grow of the code
instantiated. This situation is sometime called codeblow.
Let us to analize the problem, and see, how to avoid codeblow.
- Using C and C++ together
C and C++ sources should be compiled separatelly, but we can
link them together. Because of the different strategy to
generate external names in C and C++, we use extern "C".
- Interpositioning
An interesting "issue", when more than one external name
can be taken part in the linking. Also be care with the
left-to-write searching method of linkers.
- Order of objects at linking
Do you think, that the order of object files at linking
is not a significant issue. Well, check this small project, and
decide it yourself.
- Static members
Static members are initialized at the beginning of the program,
in order of their apperance in the source. Order between different
sources, however, not defined, and could be depending of linking
order.
- Dynamic linking issues