Portability Hints: Borland C++ 5.5.1

It is a general aim for boost libraries to be
portable. The primary means
for achieving this goal is to adhere to ISO Standard C++. However,
ISO C++ is a broad and complex standard and most compilers are
not fully conformant to ISO C++ yet. In order to achieve portability
in the light of this restriction, it seems advisable to get acquainted
with those language features that some compilers do not fully
implement yet.

This page gives portability hints on some language features of the
Borland C++ version 5.5.1 compiler. Furthermore, the appendix
presents additional problems with Borland C++ version 5.5. Borland
C++ 5.5.1 is a freely available command-line compiler for Win32
available at
http://www.borland.com/.

Each entry in the following list describes a particular issue,
complete with sample source code to demonstrate the effect.
Most sample code herein has been verified to compile with gcc 2.95.2
and Comeau C++ 4.2.44.

Preprocessor symbol

The preprocessor symbol __BORLANDC__ is defined for all
Borland C++ compilers. Its value is the version number of the
compiler interpreted as a hexadecimal number. The following table
lists some known values.

Compiler

__BORLANDC__ value

Borland C++ Builder 4

0x0540

Borland C++ Builder 5

0x0550

Borland C++ 5.5

0x0550

Borland C++ 5.5.1

0x0551

Borland C++ Builder 6

0x0560

Core Language

[using-directive] Mixing using-declarations and
using-directives

Mixing using-directives (which refer to whole namespaces)
and namespace-level using-declarations (which refer to
individual identifiers within foreign namespaces) causes ambiguities
where there are none. The following code fragment illustrates this:

Workaround: Avoid explicit template function
instantiations (they have significant problems with Microsoft Visual
C++) and pass default-constructed unused dummy arguments with the
appropriate type. Alternatively, if you wish to keep to the explicit
instantiation, you could use an explicit conversion to
std::string or declare the template function as taking a
const char * parameter.

[cmath.abs] Function double std::abs(double)
missing

Note that int std::abs(int) will be used without warning
if you write std::abs(5.1).

Similar remarks apply to seemingly all of the other standard math
functions, where Borland C++ fails to provide float and
long double overloads.

Workaround: Use std::fabs instead if
type genericity is not required.

Appendix: Additional issues with Borland C++ version 5.5

These issues are documented mainly for historic reasons. If you are
still using Borland C++ version 5.5, you are strongly encouraged to
obtain an upgrade to version 5.5.1, which fixes the issues described
in this section.

[inline friend] Inline friend functions in template classes

If a friend function of some class has not been declared before the
friend function declaration, the function is declared at the namespace
scope surrounding the class definition. Together with class templates
and inline definitions of friend functions, the code in the following
fragment should declare (and define) a non-template function "bool
N::f(int,int)", which is a friend of class N::A<int>. However,
Borland C++ v5.5 expects the function f to be declared beforehand:

This technique is extensively used in boost/operators.hpp. Giving in
to the wish of the compiler doesn't work in this case, because then
the "instantiate one template, get lots of helper functions at
namespace scope" approach doesn't work anymore. Defining
BOOST_NO_OPERATORS_IN_NAMESPACE (a define
BOOST_NO_INLINE_FRIENDS_IN_CLASS_TEMPLATES would match this case
better) works around this problem and leads to another one, see
[using-template].