Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

116 C++ Coding Standards 63. Use sufficiently portable types in a module's interface. Summary Take extra care when living on the edge (of a module): Don't allow a type to appear in a module's external interface unless you can ensure that all clients understand the type correctly. Use the highest level of abstraction that clients can understand. Discussion The more widely distributed your library, and the less control you have over the build environment of all of its clients, the fewer the types that the library can reliably use in its external interface. Interfacing across modules involves binary data ex- change. Alas, C++ doesn't specify standard binary interfaces; widely distributed li- braries in particular might need to rely on built-in types like int and char to interface with the outer world. Even compiling the same type using different build options on the same compiler can cause binary-incompatible versions of the type. Typically, either you control the compiler and options used to build the module and