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

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) 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