Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




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 ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

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

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

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

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists