From: Bernd Petrovitsch <bernd@firmix.at>
To: Alexander Neundorf <neundorf@eit.uni-kl.de>
Cc: linux-embedded@vger.kernel.org
Subject: Re: prevalence of C++ in embedded linux?
Date: Tue, 29 Jul 2008 11:47:18 +0200 [thread overview]
Message-ID: <1217324838.24988.41.camel@spike.firmix.at> (raw)
In-Reply-To: <200807291058.06240.neundorf@eit.uni-kl.de>
On Tue, 2008-07-29 at 10:58 +0200, Alexander Neundorf wrote:
> On Tuesday 29 July 2008 10:20:12 you wrote:
> > On Tue, 2008-07-29 at 09:51 +0200, Alexander Neundorf wrote:
> ...
> > Yes, one *can* use the above features and get small features. But most
> > people simply can't - if only that they use some tool/lib written in C++
> > (and coming from the "normal" world) which simply uses them without
> > thinking about space and wonder why the device won't run with "only"
> > 128MB flash and run in 16MB RAM.
>
> Well, if somebody carelessly uses general purpose apps/libs in a tiny embedded
> project he will have problems, no matter if it's C or C++.
Of course.
But it is IMHO much more easier and seductive to use the code bloating
features with C++ - especially if you don't know what to do and do not
realize (until it's too late).
Evey other potential customer asks about C++ on an embedded device. And
if you say "yes" they *expect* to use all that g++ allows. Period.
Getting exceptions and restrictions to the use of C++ (including any 3rd
party software - known and unknown) in an offer?
Please be serious.
Discussing afterwards that these templates are a very bad idea (and need
to be converted to "a pure virtual class and lots of classes" to avoid
code bloat and that it will cost a few man-weeks and calendar time)?
I can hear it already: "But you said that C++ is OK and this is plain C
++".
> > BTW why should I use C++ if I don't use any "fancy features"?
>
> If you just skip RTTI and exceptions you have enough fancy features left :-)
Hmm, does g++ has options to completely disabled these (and other)
"fancy features"? At least one could check 3rd party software more
easily if they actually use that.
Multiple inheritance[0] is in my experience not really necessary (if
ever used).
I already have "Safe C" with gcc anyways (if I want and enable some
warnings;-).
OO design is a question of design and not of the implementation
language. I can't see much difference between
- declaring a class and using a method or
- declaring a struct and use a pointer to an instance as the first
parameter in several functions.
Leaves operator/function overloading and default values for parameters.
But it adds usually libstdc++.so ....
> Just know what you're doing if you're using templates and multiple
ACK. But what is with the other 90%?
> inheritance, there is no problem with them. Templates are so much better than
> macros, and if used carefully they don't bloat the code size.
Don't get me wrong - I'm not religiously against C++ in anyway.
It's just that you *really* need to know what you do and that implies
IMHO for C++ that you must know how templates work/are implemented.
Similar for exceptions (and no, using exceptions usually doesn't save
space anywhere - at least not if your calling depth is < 100). if you
use them (or use a library that uses them).
And may need or may not need libstdc++.so - an additional piece of code
using space.
Of course, if you have 1GB of flash and 256M RAM, who cares. But most of
the devices I see are not that "fat".
In short: It is far from easy to *not* shoot yourself in the foot with
C++. At least compared to plain C.
Bernd
[0]: Yes, I know what's the difference between normal and virtual
inheritance.
--
Firmix Software GmbH http://www.firmix.at/
mobil: +43 664 4416156 fax: +43 1 7890849-55
Embedded Linux Development and Services
next prev parent reply other threads:[~2008-07-29 9:47 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-28 15:43 prevalence of C++ in embedded linux? Robert P. J. Day
2008-07-28 15:54 ` Chris
2008-07-28 15:55 ` Jamie Lokier
2008-07-28 16:15 ` Domenico Andreoli
2008-07-28 17:30 ` Matthias Kaehlcke
2008-07-28 21:47 ` Ben Nizette
2008-07-29 5:42 ` Roberto A. Foglietta
2008-08-02 4:14 ` Ben Nizette
2008-07-29 7:40 ` Marco Stornelli
2008-07-29 7:51 ` Alexander Neundorf
2008-07-29 8:20 ` Bernd Petrovitsch
2008-07-29 8:35 ` Marco Stornelli
2008-07-29 8:58 ` Alexander Neundorf
2008-07-29 9:47 ` Bernd Petrovitsch [this message]
2008-07-29 20:08 ` Leisner, Martin
2008-07-30 4:46 ` Bart Van Assche
2008-07-30 10:25 ` Jamie Lokier
2008-07-30 11:04 ` Bart Van Assche
2008-07-30 11:58 ` Haavard Skinnemoen
2008-07-30 12:38 ` Jamie Lokier
2008-07-30 13:01 ` Haavard Skinnemoen
2008-07-30 12:48 ` Bernd Petrovitsch
2008-07-30 13:07 ` Jamie Lokier
2008-07-30 13:58 ` Bernd Petrovitsch
2008-07-30 10:16 ` Jamie Lokier
2008-07-29 8:50 ` Bart Van Assche
2008-07-29 11:39 ` Richard Danter
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=1217324838.24988.41.camel@spike.firmix.at \
--to=bernd@firmix.at \
--cc=linux-embedded@vger.kernel.org \
--cc=neundorf@eit.uni-kl.de \
/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 NNTP newsgroup(s).