OSLib Namespace for C++
Tony van der Hoff
OSLib at mk-net.demon.co.uk
Mon May 29 18:25:11 BST 2000
I propose to introduce an OSLib namespace for use with g++. CFront
doesn't support namespaces, and it needs to be introduced in a
backwards-compatible way.
The way I propose to do it is to bracket all declarations in the headers
between
#if defined NAMESPACE_OSLIB
namespace OSLib {
#endif
.
.
.
#if defined NAMESPACE_OSLIB
}
#endif
Anyone wanting to use the namespace would define NAMESPACE_OSLIB before
including any OSLib headers. Unfortunately this requires proactive
involvement by the user, and on the basis that namespaces are a good
thing, that's a shame.
It would be nice to make this definition automatic, based on
#if defined __CPLUSPLUS && !defined __CC_NORCROFT
#define NAMESPACE_OSLIB
#endif
but that would not be backwards compatible. I doubt that any serious
applications have yet been written using OSLib and g++, given the bool
problem, but nonetheless, I don't think we can afford to do it.
Stroustrup suggests appending the headers with
using namespace OSLib;
thus making it global, but that seems to me to defeat the objective of a
namespace.
Comments anyone?
--
Tony van der Hoff | Mailto:tony at mk-net.demon.co.uk
| Mailto:avanderhoff at iee.org
Buckinghamshire, England | http:www.mk-net.demon.co.uk
More information about the oslib-user
mailing list