avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

AW: [avr-gcc-list] C++ on AVR 90S8515


From: Stumpf Michael
Subject: AW: [avr-gcc-list] C++ on AVR 90S8515
Date: Tue, 25 Jun 2002 12:18:56 +0200



> -----Ursprüngliche Nachricht-----
> Von: Joerg Wunsch [mailto:address@hidden]
> Gesendet: Dienstag, 25. Juni 2002 11:53
> An: Stumpf Michael
> Cc: address@hidden
> Betreff: Re: [avr-gcc-list] C++ on AVR 90S8515
>
>
> As Stumpf Michael wrote:
>
> > > Why depends the use of C++ classes on available memory?
> >
> > Because implementation of classes takes some effort :
> >
> >   - for every class there has to be a table of member
> functions (the so
> > called vtbl)
>
> Only if there are virtual methods in this class.

true

>
> >   - every member function gets an implicit argument, the
> 'this' pointer
>
> OK, that occupies a couple of registers.  However, if you implement
> similar problems in C, you most likely won't avoid passing something
> similar as a pointer to an object as well.

true again. if something has to be done (calculated) the data to work on have to be passed...

>
> >   - if a class uses virtual functions then ...
>
> ...of course resource consumption will increase a lot. ;-)  But then,
> if someone is using "true OO programming", he must be prepared to pay
> for it.  Unlike languages like Java, C++ leaves it to the programmer
> whether the true OO model (late binding) is used or whether everything
> is bound at compile-time.
>
> >   - if templates are used there maybe functions generated for every
> > combination of argument type - ...
>
> Sure.  But if you use C where you don't have templates, you just have
> to write it multiple times should you need the functionality.

I'm not really sure about it (- maybe I check out someday to accomplish my
knowledge -) but a template generates one function for every variety of args :
signed/unsigned, const and/or volatile.
Using C I'd rather use one function and let the compiler do the conversion ...
but one then should better know what one's doing. Or as mentioned further down verify the
code -

>
> > And implementing C++ means all or nothing, not only a subset.
>
> But the generated code only contains the subset required, even though
> the implementation is complete and were able to produce the full
> complexity.  That's why i wrote that one needs to be overly cautious
> to avoid waste of memory and code.  (It's usually a good idea to
> verify the compiled assembler code.)
>
right, you haven't to pay for things you don't use

> > One could argue that a smart compiler could resolve the overhead for
> > simple classes, but regarding the origin of gcc I doubt ...
>
> Why do you doubt instead of looking at the generated code?
>
right again,
BTW - is C++ allready available or just a plan?

> --
> J"org Wunsch                                         Unix
> support engineer
> address@hidden       
> http://www.interface-systems.de/~j/
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]