This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Question about empty classes
- To: egcs at cygnus dot com
- Subject: Question about empty classes
- From: Carlo Wood <carlo at runaway dot xs4all dot nl>
- Date: Mon, 9 Nov 1998 14:10:23 +0100 (CET)
Hi,
I try hard to save memory in my designs, which is why I was
unpleasantly surpriced to find out that egcs (1.1b) assigns
at least 4 bytes to any empty class :/.
For instance:
class empty {
public:
bool empty(void) { return true; }
int foobar(int i) { return i; }
};
class A : public empty {
public:
int i;
};
Gives sizeof(A) == 8
Likewise
class B {
public:
int i;
empty x;
};
gives sizeof(B) == 8
:(
Why is this? Is there a way around this?
Please CC me because I am not subbed to this list (anymore).
--
Carlo Wood <carlo@runaway.xs4all.nl>