Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


Loading

C++ and FreeRTOS

Posted by Thomas on May 13, 2008
I have been trying to get FreeRTOS 5.0 running on a dvk90can1 evaluation board using WinAVR's c++ compiler.

I'm using the port from Dr. Klaus Schaefer and trying out the his Can Driver and the following example.
http://kschaefer.eit.h-da.de/ATMEL/CAN/index.html

I have changed a few type casts in order to compile using avr-g++. But as you can see out of the below listing. The linking fails in the end. Some references to Queue.c break.

If I compile the same code using avr-gcc the linking is okay and the example runs fine on the board.

If I loose the dependences to queue.c in the example (only use the task system of FreeRTOS) the g++ compiled code runs fine.

I'm new to FreeRTOS and WinAVR. I have been looking into the FreeRTOS code and I can't figure out why these references to queue.c break when compiling with g++. The compiler don't report any errors before the linking is done.

Can someone please help me?


Build started 13.5.2008 at 07:44:11
avr-g++.exe -I"C:\Files\Data\AvrStudio\FreeRTOS\Projects\CanDriver\..\..\Source\include" -I"C:\Files\Data\AvrStudio\FreeRTOS\Projects\CanDriver\." -mmcu=at90can128 -Wall -gdwarf-2 -O0 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -DGCC
_at90can128 -MD -MP -MT main.o -MF dep/main.o.d -c ../main.c

avr-g++.exe -I"C:\Files\Data\AvrStudio\FreeRTOS\Projects\CanDriver\..\..\Source\include" -I"C:\Files\Data\AvrStudio\FreeRTOS\Projects\CanDriver\." -mmcu=at90can128 -Wall -gdwarf-2 -O0 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -DGCC
_at90can128 -MD -MP -MT can.o -MF dep/can.o.d -c ../can.c

avr-g++.exe -I"C:\Files\Data\AvrStudio\FreeRTOS\Projects\CanDriver\..\..\Source\include" -I"C:\Files\Data\AvrStudio\FreeRTOS\Projects\CanDriver\." -mmcu=at90can128 -Wall -gdwarf-2 -O0 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -DGCC
_at90can128 -MD -MP -MT frtos_can.o -MF dep/frtos_can.o.d -c ../frtos_can.c

avr-g++.exe -I"C:\Files\Data\AvrStudio\FreeRTOS\Projects\CanDriver\..\..\Source\include" -I"C:\Files\Data\AvrStudio\FreeRTOS\Projects\CanDriver\." -mmcu=at90can128 -Wall -gdwarf-2 -O0 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -DGCC
_at90can128 -MD -MP -MT tasks.o -MF dep/tasks.o.d -c ../../../Source/tasks.c

avr-g++.exe -I"C:\Files\Data\AvrStudio\FreeRTOS\Projects\CanDriver\..\..\Source\include" -I"C:\Files\Data\AvrStudio\FreeRTOS\Projects\CanDriver\." -mmcu=at90can128 -Wall -gdwarf-2 -O0 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -DGCC
_at90can128 -MD -MP -MT queue.o -MF dep/queue.o.d -c ../../../Source/queue.c

avr-g++.exe -I"C:\Files\Data\AvrStudio\FreeRTOS\Projects\CanDriver\..\..\Source\include" -I"C:\Files\Data\AvrStudio\FreeRTOS\Projects\CanDriver\." -mmcu=at90can128 -Wall -gdwarf-2 -O0 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -DGCC
_at90can128 -MD -MP -MT list.o -MF dep/list.o.d -c ../../../Source/list.c

avr-g++.exe -I"C:\Files\Data\AvrStudio\FreeRTOS\Projects\CanDriver\..\..\Source\include" -I"C:\Files\Data\AvrStudio\FreeRTOS\Projects\CanDriver\." -mmcu=at90can128 -Wall -gdwarf-2 -O0 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -DGCC
_at90can128 -MD -MP -MT heap_1.o -MF dep/heap_1.o.d -c ../../../Source/portable/MemMang/heap_1.c

avr-g++.exe -I"C:\Files\Data\AvrStudio\FreeRTOS\Projects\CanDriver\..\..\Source\include" -I"C:\Files\Data\AvrStudio\FreeRTOS\Projects\CanDriver\." -mmcu=at90can128 -Wall -gdwarf-2 -O0 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -DGCC
_at90can128 -MD -MP -MT port.o -MF dep/port.o.d -c ../../../Source/portable/GCC/AT90CAN128/port.c

avr-g++.exe -I"C:\Files\Data\AvrStudio\FreeRTOS\Projects\CanDriver\..\..\Source\include" -I"C:\Files\Data\AvrStudio\FreeRTOS\Projects\CanDriver\." -mmcu=at90can128 -Wall -gdwarf-2 -O0 -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -DGCC
_at90can128 -MD -MP -MT croutine.o -MF dep/croutine.o.d -c ../../../Source/croutine.c

avr-g++.exe -mmcu=at90can128 -Wl,-Map=CanDriver.map main.o can.o frtos_can.o tasks.o queue.o list.o heap_1.o port.o croutine.o -o CanDriver.elf
main.o: In function `receive_function':
C:\Files\Data\AvrStudio\FreeRTOS\Projects\CanDriver\default/../main.c:113: undefined reference to `xQueueGenericReceive'
frtos_can.o: In function `xCANQueueCreate':
C:\Files\Data\AvrStudio\FreeRTOS\Projects\CanDriver\default/../frtos_can.c:35: undefined reference to `xQueueCreate'
frtos_can.o: In function `CAN_callback(CAN_packet*, unsigned char)':
C:\Files\Data\AvrStudio\FreeRTOS\Projects\CanDriver\default/../frtos_can.c:27: undefined reference to `xQueueGenericSendFromISR'
make: *** [CanDriver.elf] Error 1
Build failed with 3 errors and 0 warnings...

RE: C++ and FreeRTOS

Posted by Dave on May 13, 2008
This could be to do with the data hiding. Queue.c defines xQueueHandle as a pointer to a struct. Queue.h defines xQueueHandle as a pointer to void. If you make them both the same thing it will probably link. To do this you could move the queue data structure definition from queue.c to queue.h.

RE: C++ and FreeRTOS

Posted by Thomas on May 13, 2008
Thanks a lot. That solved it.

I have spent hours trying to figure this out.

/Thomas


[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ Sitemap ]    [ ]


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

NXP tweet showing LPC5500 (ARMv8-M Cortex-M33) running FreeRTOS.

Meet Richard Barry and learn about running FreeRTOS on RISC-V at FOSDEM 2019

Version 10.1.1 of the FreeRTOS kernel is available for immediate download. MIT licensed.

View a recording of the "OTA Update Security and Reliability" webinar, presented by TI and AWS.


Careers

FreeRTOS and other embedded software careers at AWS.



FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Renesas

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner