Quality RTOS & Embedded Software

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


G++ and C in FreeRTOS

Posted by Bill Yang on February 17, 2010

I have a question regarding using different tool chain in FreeRTOS demo. I have a demo called FreertosLwipExemplo1 that is FreeRTOS + lwIP + Keil + LM3S web server demo. I think the source code was created and compiled by G++. When I compiled it with Keil RVMDK C compiler, I got the compiling error as below.

xSemaphoreHandle ETHRxBinSemaphore [MAX_ETH_PORTS] ={ [0 ... (MAX_ETH_PORTS - 1)] = NULL };
ETHIsr.c(82): error: #29: expected an expression

Actually I am not familiar with C++ or G++, but I believe that initializing a semaphore handler using [0 ... ] = NULL is for C++/G++, but did not for the C syntax, so I just commented the these [0 .....().] and left the NULL there. The compile is passed now.

I wonder if any suggestion or ideal about my question.


RE: G++ and C in FreeRTOS

Posted by MEdwards on February 17, 2010
Don't think you asked a question.

RE: G++ and C in FreeRTOS

Posted by Bill Yang on February 17, 2010
My question if this initialization sentence is a C++/G++ stype?
xSemaphoreHandle ETHRxBinSemaphore [MAX_ETH_PORTS] ={ [0 ... (MAX_ETH_PORTS - 1)] = NULL };

If using below one to replace above one, is it OK?
xSemaphoreHandle ETHRxBinSemaphore [MAX_ETH_PORTS] ={ NULL };


RE: G++ and C in FreeRTOS

Posted by MEdwards on February 17, 2010
You definitely cannot use C++ code in your C program, if that is what you are asking. Initialize it any way you like, this is just a C question and again not FreeRTOS related.

RE: G++ and C in FreeRTOS

Posted by Richard Damon on February 18, 2010
edwards, while you can't (in general) use C++ syntax in a C program, FreeRTOS is compatible with C++ (I know, as I use it this way in a project, and Richard has placed the appropriately guarded extern "C" statements in the headers so it works). Note that if ETHRxBinSemaphore is a global, then the language definition (C and C++) defines that it will be zero/NULL initialized automatically.

[ 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.

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.


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


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