G++ and C in FreeRTOS

yyang2000 wrote on Wednesday, 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  ={  = 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  = NULL is for C++/G++, but did not for the C syntax, so I just commented the these  and left the NULL there. The compile is passed now.

I wonder if any suggestion or ideal about my question.

Thanks,
Bill

edwards3 wrote on Wednesday, February 17, 2010:

Don’t think you asked a question.

yyang2000 wrote on Wednesday, February 17, 2010:

My question if this initialization sentence is a C++/G++ stype?
xSemaphoreHandle ETHRxBinSemaphore  ={  = NULL };

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

Thanks,
Bill

edwards3 wrote on Wednesday, 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.

richard_damon wrote on Thursday, 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.