I'm looking for the best solution to write cross-platform software, aka code that I write and that I have to interface with different libraries and platforms each time.
What I consider the easiest part, correct me if I'm wrong, is the definition of new types, all I have to do is to write an hpp file with a list of
typedefs, I can keep the same names for each new type across the different platforms so my codebase can be shared without any problem.
typedefs also helps me to redefine a better scope for my types in my code.
I will probably end up having something like this:
include |-windows | |-types.hpp |-linux | |-types.hpp |-mac |-types.hpp
For the interfaces I'm thinking about the same solution used for the types, a series of hpp files, probably I will write all the interfaces only once since they rely on the types and all "cross-platform portability" is ensured by the work done on the types.
include | |-interfaces.hpp | |-windows | |-types.hpp |-linux | |-types.hpp |-mac | |-types.hpp
For classes and methods I do not have a real answer, I would like to avoid 2 things:
- the explicit use of pointers
- the use of templates
I want to avoid the use of the pointers because they can make the code less readable for someone and I want to avoid templates just because if I write them, I can't separate the interface from the definition.
What is the best option to hide the use of the pointers?
I would also like some words about macros and how to implement some OS-specifics calls and definitions.