C++ pure virtual base class memory consumption
fueb
fueb@gmx.net
Thu Aug 23 04:28:00 GMT 2012
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:
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?
--
View this message in context: http://old.nabble.com/C%2B%2B-pure-virtual-base-class-memory-consumption-tp34325972p34325972.html
Sent from the Sourceware - newlib list mailing list archive at Nabble.com.
More information about the Newlib
mailing list