This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Re: C++ pure virtual base class memory consumption
- From: Sebastian Huber <sebastian dot huber at embedded-brains dot de>
- To: newlib at sourceware dot org
- Date: Tue, 21 Aug 2012 09:38:29 +0200
- Subject: Re: C++ pure virtual base class memory consumption
- References: <34325972.post@talk.nabble.com>
On 08/20/2012 08:52 PM, fueb wrote:
Hi out there, I hope someone can give me a hint on a problem building a c++
static library using newlib and lpcxpresso. Everything works fine, but I
have a size-problem.
I have got a class that has pure virtual methods. Another class derives this
base class and implements the function:
Code:
class A {
public:
virtual void method() = 0;
}
class B : public A {
virtual void method() { // do something }
}
Using the above code links appr. 60kB more code from newlib into the
application than if I use the following code, where the base class method is
already implemented but overwritten in the derived class:
Are you sure this code is from Newlib and not GCC?
Code:
class A {
public:
virtual void method() {} // <-- the only change
}
class B : public A {
virtual void method() { // do something }
}
I know that gcc for other small devices is capable to build this with
smaller code, probably with a commandline switch, but I do not know how.
Does someone have a hint on how I could prevent the compiler to
auto-implement that much functions used for the pure virtual class?
I suppose this is due to the abort handler with pretty printing pulled in by a
pure virtual function. You should look at the map file of the linker. See also
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43852
--
Sebastian Huber, embedded brains GmbH
Address : Obere Lagerstr. 30, D-82178 Puchheim, Germany
Phone : +49 89 18 90 80 79-6
Fax : +49 89 18 90 80 79-9
E-Mail : sebastian.huber@embedded-brains.de
PGP : Public key available on request.
Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.