C++ stylistic concerns?
etierra at gmail.com
Tue Mar 20 20:17:34 MDT 2007
On 3/20/07, Steve <smorrey at gmail.com> wrote:
> So I tried a new style I had read about.
> In this style, you create a .h for your basic definitions on each
> system, then you place a few #ifdefs for each platform and #include a
> platform specific header to handle the implementation details.
The wxWidgets cross-platform GUI toolkit uses this basic approach for
the internal workings of the library. You'll often find that most
wxWidgets classes have an abstract base class that defines all common
virtual functions that require an implementation, and
platform-specific headers and source that implement that base class.
There's a lot of this in the code:
#elif defined(__SMARTPHONE__) && defined(__WXWINCE__)
It is an extremely tedious job of maintaining the code, but most
cross-platform C++ developers understand that this is the price you
pay for a cross-platform code base. This is actually the whole reason
that the wxWidgets library exists. It does all this work and
maintenance for you, and you have a simple code base that requires
very few preprocessor platform checks. It's actually possible to write
an application without a single platform check.
In fact, from what you describe, you could actually just build your
application on top of wxWidgets and not have to worry about this. It
has cross-platform support for OpenGL as well as playing media (audio
More information about the PLUG