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 exchange. Alas, C++ doesn’t specify standard binary interfaces; widely distributed libraries in particular might need to rely on built-in types like int and char to interface ...

Get C++ Coding Standards: 101 Rules, Guidelines, and Best Practices now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.