This is the mail archive of the c++-embedded@sourceware.cygnus.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: biggest deterrant to using C++?



>On Tue, 25 Aug 1998 20:53:39 +0200, Michael Bruck wrote:
>
>>You waste the space for the pointer (Thing::data). This is ok
>>if you have big classes (many values). But if you have two or
>>three bytes per class this is unacceptable. It also doesn't
>>make your programs easier to read (ok, with a 40KB
>>macro-header :)
>
>Small classes with virtual methods just don't ROM effectively. Related

Hey, that's not a solution! The point is that they don't ROM effectivly
because the language designers didn't care about systems with
limited resources. (do I need to explain this more detailed ?) And
there are ways to easily change this.

>question: Do compilers put the vtable in the text segment so that it
>can be ROM'd?

g++ puts them into .rodata. I think that's something that every compiler
is able to do without any extra logic. But the probability that compiler XY
puts vtables into .text/.rodata is the same as for global consts.

>
>The case where I was asking the question involved a big command table
>with fixed-size string buffers for each command and a series of flag
>bytes. I currently build this in assembler and use a C routine to scan
>the tables. Assembler is used because the tables have 26 internal
>labels to allow quick jumping to command entries starting with a
>specific character. (I inherited this design. In retrospect I could use
>26 independent tables or use binary search, since the entries are of
>fixed size.) Obviously this is the kind of bulky data that could
>benefit from the architecture I described.
>

Usually one decides to use C++ to make development easier (f.e. using the
STL).
But I don't know how to make my libraries more portable, the sources more
readable and reduce the bugs when I use 50 lines of code just to wrap a
struct that should go into ROM.

In the case that you described above I can't see how you could use the new
concepts that C++ offers. (classes, inheritance ... maybe some STL
algorithms)
In my case I wanted to make use of them and it's impossible because of some
unimportant details.


Micha






Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]