Page 2 of 3

Re: Looking for help with my C++ thread class

Posted: Mon Apr 18, 2011 7:49 am
by Giovanni
There is a new C++ demo under ./demos/ARMCM3-STM32F103-G++, you may start from there.

There are changes to the ch.ld file, to the Makefile, to the C++ kernel wrapper and a new unified startup file that supports several new features.

Giovanni

Re: Looking for help with my C++ thread class

Posted: Sat Sep 17, 2011 9:54 am
by JetForMe
It looks like the new C++ support still isn't available for GCC/ARM AT91SAM7. How hard would it be for you to update that port to include it? I can try myself, but I fear it will be very hard to get it working (without JTAG tools).

Thanks,
Rick

Re: Looking for help with my C++ thread class

Posted: Sat Sep 17, 2011 10:24 am
by Giovanni
Hi Rick,

The existing C++ wrapper should work perfectly for the AT91SAM7 too, it is not platform dependent and there is a LPC2148 demo proving it works on ARM7. You just have to modify a AT91 demo by changing the makefile like in the LPC demo.

Lack of a JTAG probe makes everything harder. Anyway, give it a try, If you are unable to make it work I'll give it some bandwidth during next week.

Giovanni

Re: Looking for help with my C++ thread class

Posted: Sat Sep 17, 2011 10:32 am
by JetForMe
Thanks, Giovanni, I'll give it a shot this weekend.

One thing I ran into was a link problem with delete and pure virtual:


src/ColorAnimator.o: In function `~ColorAnimatorDelegate':
/Users/rmann/Projects/ISSLamp/repo/trunk/Firmware/src/ColorAnimator.cpp:77: undefined reference to `operator delete(void*)'
src/ColorAnimator.o:(.rodata._ZTV21ColorAnimatorDelegate[vtable for ColorAnimatorDelegate]+0x10): undefined reference to `__cxa_pure_virtual'
src/Flower.o: In function `~Flower':
/Users/rmann/Projects/ISSLamp/repo/trunk/Firmware/src/Flower.h:33: undefined reference to `operator delete(void*)'
collect2: ld returned 1 exit status


Does your new stuff fix that?

Thanks!

Re: Looking for help with my C++ thread class

Posted: Sat Sep 17, 2011 10:35 am
by Giovanni
There is no support for destructors because the C++ support is limited, there is no allocation currently. Probably this is the cause of that error.

RTTI and exceptions are not supported too.

Giovanni

Re: Looking for help with my C++ thread class

Posted: Sat Sep 17, 2011 10:41 am
by JetForMe
RTTI and exceptions are a lot easier to live without, but destructors are very important.

Re: Looking for help with my C++ thread class

Posted: Tue Sep 20, 2011 3:12 pm
by Giovanni
It is something that could be added when that C++ wrapper will be improved, it is quite old now, unfortunately the bandwidth is limited and there are more urgent pending developments right now.

Giovanni

Re: Looking for help with my C++ thread class

Posted: Tue Sep 20, 2011 4:21 pm
by mabl
That really is unfortunate. I also run into the C++ limitations quite often. For now I'm fine with the wrapper class, but improved C++ language support would really be great. Is there any documentation on the internet on what is missing and how to do it?

EDIT: I know it is an awful hack, but in the meantime, would linking to stdc++ help? (Assuming I have enough of ROM)

Re: Looking for help with my C++ thread class

Posted: Tue Sep 20, 2011 5:54 pm
by Giovanni
The wrapper is just plan and simple C++, there are no hacks so supporting the whole stdc++ would allow exceptions, destructors and everything else. The problem is making stdc++ work with the RTOS but this is an integration effort not a development effort.

I imagine that stdc++ requires at least allocation services for the "new" operator, linker scripts may require changes.

Giovanni

Re: Looking for help with my C++ thread class

Posted: Tue Sep 20, 2011 6:45 pm
by mabl
Hi Giovanni,

I just made some test with libstdc++. It uses standard malloc for allocation and has some os layer support for newlib (mainly ctype). In my tests I can create objects with new, and the constructor is called as well. Though I'm pretty sure malloc will collide with the ChibiOs allocator, right?

So basically I'll have to figure out how to map malloc to the ChibiOs.