Boost logo

Boost :

From: Rob Williscroft (rtw_at_[hidden])
Date: 2004-01-03 10:37:58


Pavel Vozenilek wrote:
> Empty class in Borland C++ Builder has by default 8 bytes. These 8 bytes are
> not removed by EBO and only increase descendants size.
>
> boost::noncopyable is such class.
>
> Could it be please changed to:
>
> --------------

#if (defined __BORLANDC__) && (__BORLANDC__ <= 0x564)
#pragma option -Ve // Enable EBO
#include <pshpack1.h>
#endif

> class noncopyable
> {
> #if (defined __BORLANDC__) && (__BORLANDC__ <= 0x564)
> char dummy; // BCB would use 8 bytes by default
> #endif
> protected:
> ....
> --------------
>

};

#if (defined __BORLANDC__) && (__BORLANDC__ <= 0x564)
#include <poppack.h>
#endif

This is the programme I tested with:

#include <iostream>

#pragma option -Ve
#include <pshpack1.h>
struct empty
{
};
#include <poppack.h>

struct astruct
{
   int i;
};

struct derived: empty
{
   astruct a;
};

int main()
{
   using namespace std;

   cerr << "empty: " << sizeof( empty ) << "\n";
   cerr << "astruct: " << sizeof( astruct ) << "\n";
   cerr << "derived: " << sizeof( derived ) << "\n";
   cerr << "int: " << sizeof( int ) << "\n";
}

I get:

empty: 1
astruct: 4
derived: 4
int: 4

With bcc32 5.4 and 5.6.4, default packing for 5.6.4 is 8 bytes and 4
bytes for 5.4 (according to the help files), 5.4 is the most updated
BCB 4.0 compiler.

-- 
Rob.
-- 
http://www.victim-prime.dsl.pipex.com/

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