From: "Michael Bruck" <mbruck@rft.de>
To: <c++-embedded@cygnus.com>
Subject: Re: biggest deterrant to using C++?
Date: Sun, 23 Aug 1998 18:37:00 -0000 [thread overview]
Message-ID: <001401bdceff$cebb36c0$400581c0@avh.ins-coin.de> (raw)
One of my bigger problems with using C++ in embedded projects is the
way ctors are handled. When you have global class variables the
compiler (in my case egcs) generates lots of constructor/destructor
calls for them, where they are completely uneccessary. For example:
struct general_thing {
int weight;
general_thing(int _weight = 0) : weight(_weight) {}
virtual bool get() = 0;
};
struct atom_bomb : public general_thing {
long price;
atom_bomb(long _price, int _weight = 1000) : price(_price),
general_thing(_weight) {}
virtual bool get();
};
const atom_bomb my_bomb(50, 100);
I would like to have my_bomb somewhere in the ROM. And the example above
should not generate any code as long as I don't call the constructors in
another context. What happens is, that the compiler always generates
a function for each source file that calls all the constructors and
then generates a section that contains the pointer to that function.
These sections from all files are then linked together into a table of
function pointers and the init-functions of all global objects are
called at program startup through this table. This is ok if my
constructors are doing something other than just copying around values.
This would cause in most situations just some overhead,
but if you want to use ROM it's impossible to use (virtual) classes.
Micha
next reply other threads:[~1998-08-23 18:37 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
1998-08-23 18:37 Michael Bruck [this message]
-- strict thread matches above, loose matches on Subject: below --
1998-08-26 10:38 Michael Bruck
1998-08-25 18:04 Kenneth Porter
1998-08-25 11:57 Michael Bruck
1998-08-24 18:39 Kenneth Porter
1998-08-17 16:43 Kenneth Porter
1998-08-14 16:04 Kenneth Porter
1998-08-14 10:18 Saffi Hartal
1998-08-12 10:44 Brendan Kehoe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='001401bdceff$cebb36c0$400581c0@avh.ins-coin.de' \
--to=mbruck@rft.de \
--cc=c++-embedded@cygnus.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).