Boost logo

Boost :

From: Pavel Vozenilek (pavel_vozenilek_at_[hidden])
Date: 2004-01-06 02:33:36


"David Abrahams" <dave_at_[hidden]> wrote in

[fix to use EBO on Borland C++ Builder discussion]
>
> As soon as we can get someone to check the new compiler, I'll apply
> these changes to the trunk and the release branch.
>
>
I checked the new compiler (still in beta): it supports EBO automatically.

Friend of my tried it on Kylix and it behaves just like BCB in this regard.

So this seems to be the best solution to support EBO for empty classes:
(Rob Williscroft came with idea of using #pragmas)

__________________________

#if (defined __BORLANDC__) && (__BORLANDC__ <= 0x570) // Kylix, BCB 6 and
down
# pragma warn -8059 // structure size has changed
# pragma option push -Ve // enable EBO
# pragma pack(push, 1) // EBO requires tight packing to act up
#endif

class noncopyable {
 ...
};

#if (defined __BORLANDC__) && (__BORLANDC__ <= 0x570)
# pragma pack(pop)
# pragma option pop
# pragma warn .8059
#endif

__________________________

Rationale:
  - while using dummy byte has the same effect, it is ugly, prone to
    maintenance problems and non-educative

  - using Borland supplied <pshpack1.h> is avoided because:
      - it would slow compilation futher down
      - it was buggy in BCB 6 until patch 4

  - BOOST_WORKAROUND isn't used because including <config.hpp>
    would only slow down compilation of the tiny <noncopyable.hpp>

  - object layout should stay always the same, no matter what

The fix doesn't not produce any warnings and should work with
arbitrary BCB settings. I put it into my code and have no problems
so far.

There are other places which may use this trick too: e.g. iterator_base.

/Pavel


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk