[En-Nut-Discussion] C++ compiling problem with virtual methods (aligment of 'x' is greater than maximum object file aligment)

Gervasio Varela gervarela at picandocodigo.com
Thu Feb 22 22:14:41 CET 2007


Hi Matthias,


welcome to the club of C++ programmers on Ethernut.
> Since I do not have v1 Charon board I can not say what is going wrong.
> However regarding Ethernut 3 (arm) I did some adaptation and so far as I
> know PURE virtual functions are not supported in current version.


After an afternoon of tests, I have come to the conclusion that in AVR-GCC
pure virtual functions aren't supported neither :).

However
> I remember I had some problems also with virtual functions, but when I
> remember right that was during linking.
>
I guess with some modifications in the makefiles (compiler / linker flags)
> it should be possible.


Yes, at last I managed to find the file with the avr-g++ flags defintions
and I removed the '-Wall -Werrror' in order to achieve that the compilation
process doesn't get stoped by those warnings.

Now the program compiles and links well (but the warnings continue there),
and even runs well! :) (virtual functions are running ok)

My primary concerns were about the size of the resulting program (I'm
implementing a sort of remote object system for little embedded systems),
but it seems to scale well, even for the 128K ROM of the Charon2 :D.

OK - not at all very helpful my words - just a comment.


Thank you very much Matthias.

Finally, some of my first impresions testing C++ with AVR-GCC, to see if
some are incorrent (I have little experience with C++) and somebody knowns a
tip about it:

- You can't use PURE virtual functions
- You can't use new or delete with arrays (ex: SomeObject * foo = new
SomeObject[len]; delete [] foo), use malloc and free instead?

Best regards.


-- 
###################################
#    Gervasio Varela                               #
#    gervarela at picandocodigo.com         #
#    http://www.picandocodigo.com          #
###################################



More information about the En-Nut-Discussion mailing list