Click to See Complete Forum and Search --> : Platform independent classes


sszd
April 8th, 2008, 06:16 PM
Does anybody know of any good links that discuss designing (or converting) C++ classes that require platform independence (or at least with a set of specific platforms in mind). The idea is to not riddle the code with tons of #ifdef's. In my own mind, a good link that talks about designing such classes should take into consideration calls to library functions that may have slightly different signatures and/or return values on different platforms, different system include files between the various platforms, etc. I seem to be striking out googling for this. Thanks for your help.

Lindley
April 8th, 2008, 06:25 PM
So long as you avoid using platform-dependent libraries, and user minimal wrappers where you must do so, it really isn't that hard.

_uj
April 8th, 2008, 09:53 PM
Have a look at the Bridge Design Pattern.

JohnW@Wessex
April 9th, 2008, 06:35 AM
You could create a base interface class with the cross platform functionality but with pure virtual platform dependent functions. Then define platform dependent concrete classes derived from it.

sszd
April 9th, 2008, 10:04 AM
You could create a base interface class with the cross platform functionality but with pure virtual platform dependent functions. Then define platform dependent concrete classes derived from it.
Actually, this is similar to the route I was thinking about taking. I just didn't know whether it would be the best path to start down, that's why I was wondering about other types of solutions that I haven't thought about or just aren't aware of. Thanks for your input.
Have a look at the Bridge Design Pattern.
I'm not familar with this particular design pattern, but I'll take a look at it. Thanks.