FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [June 2008 Threads] IAR & static_cast<>Posted by Thomas on June 4, 2008 I'm trying to use FreeRTOS together with C++.
I'm using IAR AVR compiler.
All of FreeRTOS source files are compiled using the C compiler and my own code using Extended Embedded C++ compiler. All the code are compiled and linked togther without errors.
Inspired by a richard_damon post I've made a Runable class, see below.
Running my code I get an RStack warning (JTAGICE mkII) Wed Jun 04 11:49:06 2008: Target reset Wed Jun 04 11:49:16 2008: Program exit reached. Wed Jun 04 11:49:17 2008: The stack 'RStack' is filled to 100% (32 bytes used out of 32). The warning threshold is set to 90.%
I've traced it down to being this static_cast causing the trouble.
(static_cast<Runable*>(parm))->Run();
If I comment the static_cast and uncomment the loop causing a led to flash everything works fine.
I have tried the same code using winavr c++ compiler and it works. Using the winavr compiler I compile everything using the c++ compiler. Therefore I have to change some cast here and there in the FreeRTOS code in order to satisfy the c++ compiler. When using IAR I can compile a "clean" FreeRTOS (without changing anything) using C compiler and my own code using C++. My guess is that its the reason for my troubles.
Can someone give me an explanation or even a way to fix it?
/Thomas
// runable.c
#include "runable.h"
//***************************************************** Runable::Runable(unsigned priority, unsigned stacksize) { #if INCLUDE_vTaskDelayUntil lastWakeTime = NULL; #endif xTaskCreate(&run, "", stacksize, this, priority, &handle); }
//***************** Runable::~Runable() { #if INCLUDE_vTaskDelete vTaskDelete(handle); #endif }
#if INCLUDE_vTaskSuspend
//********************* void Runable::Suspend() { vTaskSuspend(handle); }
//******************** void Runable::Resume() { vTaskResume(handle); }
#endif
#if INCLUDE_vTaskDelay
//************************************* void Runable::Sleep(portTickType delay) { vTaskDelay(delay); }
#endif
#if INCLUDE_vTaskDelayUntil
//********************************************** void Runable::SleepUntil(portTickType increment) { if (lastWakeTime == NULL) lastWakeTime = xTaskGetTickCount(); vTaskDelayUntil(&lastWakeTime, increment); }
#endif
//*************************** void Runable::run(void* parm) { (static_cast<Runable*>(parm))->Run(); /* for(;;) { PORTA = (PORTA & ~0x01) | (~PORTA & 0x01); vTaskDelay( 100 ); } */ }
RE: IAR & static_cast<>Posted by Richard on June 5, 2008 So the problem seems to be when linking C with C++ code. Is this correct? Can you compile the whole thing as C++ as when using the WinAVR compiler?
Regards.
RE: IAR & static_cast<>Posted by Thomas on June 9, 2008 I managed to figure it out. I had some errors in my port causing the stack to be currupt.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|