This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
compile error when initializing descendant struct
- From: "Dave Bender" <codehero at gmail dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Wed, 9 Apr 2008 18:06:42 -0400
- Subject: compile error when initializing descendant struct
Dear list,
When I attempt to compile the following code (test2.cpp):
struct A {
int x;
};
struct B : public A {
int y;
};
const B b = {1, 2};
g++ gives the following error:
test2.cpp:9: error: scalar object 'b' requires one element in initializer
My goal is to incorporate a large set of structs in a DSO (so that
they reside in the read only section). I don't see why this code
should not compile.
Thanks,
-Dave