From: Rob Stewart (stewart_at_[hidden])
Date: 2004-08-25 10:49:57
From: "Mathew Robertson" <mathew.robertson_at_[hidden]>
> case in point:
> FreeBSD doesn't provide the "lround()" C99 function - yet Linux
> If I need to round a double to a long, what function do I call
> that will be portable?
> The only real choice I have is to re-implement the lround()
> function so that at minimum, it gets enabled on FreeBSD.
> Given that I have had to implement a non-OS based version of a
> function, I then ask myself, "Why bother #ifdef'ing around the
> custom function - why dont I just use the one that I am
A good reason to revert to the platform functionality is to avoid
code bloat. Your framework can be lighter on those platforms
that already provide what you need.
Another reason is so that, in the future, if a piece of emulated
functionality is available on all platforms, you can defer to the
platform implementation in all cases and eliminate the emulation
To make that work, of course, your library must provide its own
interface to the functionality which can be directed to the
emulation or platform specific implementation. You could use a
"platform abstraction layer" upon which to build everything
else. Once the PAL was implemented for a given platform,
everything else in the library and in client code would just
> Getting back to what was origonally said - if one platform
> implements something that another platform doesn't, how can a
> cross platform library not re-invent the the wheel for that
> crummy platform?
That's not reinventing the wheel for that "crummy platform," it's
implementing it. What's reinvention is ignoring the existing
implementation on the other platforms.
-- Rob Stewart stewart_at_[hidden] Software Engineer http://www.sig.com Susquehanna International Group, LLP using std::disclaimer;