Quality RTOS & Embedded Software

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




Loading

G++ and C in FreeRTOS

Posted by Bill Yang on February 17, 2010
Hi,

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.

Thanks,
Bill

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 };

Thanks,
Bill

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




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

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

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