I'm trying to port an application that was originally written for mbed (https://os.mbed.com/teams/Xsens/code/MTi-1_example/file/cb7fbf7821b5/main.cpp/). This application uses MemoryPools and Queues, as far as I understand from the documentation the queues of mbed resemble a lot the mailboxes of ChibiOS. In order to be able to re-use most of the original code, I tried to refactor the code to ChibiOS. One of the things that I did is this (create MemoryPool for one message):
Code: Select all
MemoryPool g_messagePool((size_t)(sizeof(XbusMessage)), NULL);
However, I get compiler errors:
Code: Select all
arm-none-eabi-g++ -c -mcpu=cortex-m4 -O2 -ggdb -fomit-frame-pointer -falign-functions=16 -ffunction-sections -fdata-sections -fno-common -flto -fno-rtti -Wall -Wextra -Wundef -Wa,-alms=build/lst/xbus_thread.lst -DCORTEX_USE_FPU=FALSE -DTHUMB_PRESENT -mno-thumb-interwork -DTHUMB_NO_INTERWORKING -MD -MP -MF .dep/xbus_thread.o.d -mthumb -DTHUMB -I. -I../../chibios176/os/license -I../../chibios176/os/common/startup/ARMCMx/compilers/GCC -I../../chibios176/os/common/startup/ARMCMx/devices/STM32F3xx -I../../chibios176/os/common/ext/CMSIS/include -I../../chibios176/os/common/ext/CMSIS/ST/STM32F3xx -I../../chibios176/os/rt/include -I../../chibios176/os/common/oslib/include -I../../chibios176/os/common/ports/ARMCMx -I../../chibios176/os/common/ports/ARMCMx/compilers/GCC -I../../chibios176/os/hal/osal/rt -I../../chibios176/os/hal/include -I../../chibios176/os/hal/ports/common/ARMCMx -I../../chibios176/os/hal/ports/STM32/STM32F3xx -I../../chibios176/os/hal/ports/STM32/LLD/ADCv3 -I../../chibios176/os/hal/ports/STM32/LLD/CANv1 -I../../chibios176/os/hal/ports/STM32/LLD/DACv1 -I../../chibios176/os/hal/ports/STM32/LLD/DMAv1 -I../../chibios176/os/hal/ports/STM32/LLD/EXTIv1 -I../../chibios176/os/hal/ports/STM32/LLD/GPIOv2 -I../../chibios176/os/hal/ports/STM32/LLD/I2Cv2 -I../../chibios176/os/hal/ports/STM32/LLD/RTCv2 -I../../chibios176/os/hal/ports/STM32/LLD/SPIv2 -I../../chibios176/os/hal/ports/STM32/LLD/TIMv1 -I../../chibios176/os/hal/ports/STM32/LLD/USARTv2 -I../../chibios176/os/hal/ports/STM32/LLD/USBv1 -I../../chibios176/os/hal/ports/STM32/LLD/xWDGv1 -I./boards/SensorSlave -I../../chibios176/test/lib -I../../chibios176/test/rt/source/test -I./Ecat/Inc -I./Xsens/Inc -I../../chibios176/os/various/cpp_wrappers -I../../chibios176/os/hal/lib/streams -I../../chibios176/os/various ./Xsens/Src/xbus_thread.cpp -o build/obj/xbus_thread.o
arm-none-eabi-g++ -c -mcpu=cortex-m4 -O2 -ggdb -fomit-frame-pointer -falign-functions=16 -ffunction-sections -fdata-sections -fno-common -flto -fno-rtti -Wall -Wextra -Wundef -Wa,-alms=build/lst/main.lst -DCORTEX_USE_FPU=FALSE -DTHUMB_PRESENT -mno-thumb-interwork -DTHUMB_NO_INTERWORKING -MD -MP -MF .dep/main.o.d -mthumb -DTHUMB -I. -I../../chibios176/os/license -I../../chibios176/os/common/startup/ARMCMx/compilers/GCC -I../../chibios176/os/common/startup/ARMCMx/devices/STM32F3xx -I../../chibios176/os/common/ext/CMSIS/include -I../../chibios176/os/common/ext/CMSIS/ST/STM32F3xx -I../../chibios176/os/rt/include -I../../chibios176/os/common/oslib/include -I../../chibios176/os/common/ports/ARMCMx -I../../chibios176/os/common/ports/ARMCMx/compilers/GCC -I../../chibios176/os/hal/osal/rt -I../../chibios176/os/hal/include -I../../chibios176/os/hal/ports/common/ARMCMx -I../../chibios176/os/hal/ports/STM32/STM32F3xx -I../../chibios176/os/hal/ports/STM32/LLD/ADCv3 -I../../chibios176/os/hal/ports/STM32/LLD/CANv1 -I../../chibios176/os/hal/ports/STM32/LLD/DACv1 -I../../chibios176/os/hal/ports/STM32/LLD/DMAv1 -I../../chibios176/os/hal/ports/STM32/LLD/EXTIv1 -I../../chibios176/os/hal/ports/STM32/LLD/GPIOv2 -I../../chibios176/os/hal/ports/STM32/LLD/I2Cv2 -I../../chibios176/os/hal/ports/STM32/LLD/RTCv2 -I../../chibios176/os/hal/ports/STM32/LLD/SPIv2 -I../../chibios176/os/hal/ports/STM32/LLD/TIMv1 -I../../chibios176/os/hal/ports/STM32/LLD/USARTv2 -I../../chibios176/os/hal/ports/STM32/LLD/USBv1 -I../../chibios176/os/hal/ports/STM32/LLD/xWDGv1 -I./boards/SensorSlave -I../../chibios176/test/lib -I../../chibios176/test/rt/source/test -I./Ecat/Inc -I./Xsens/Inc -I../../chibios176/os/various/cpp_wrappers -I../../chibios176/os/hal/lib/streams -I../../chibios176/os/various main.cpp -o build/obj/main.o
In file included from main.cpp:21:0:
./Xsens/Inc/xbus_thread.hpp:59:27: error: expected identifier before '(' token
MemoryPool g_messagePool((size_t)(sizeof(XbusMessage)), NULL);
^
./Xsens/Inc/xbus_thread.hpp:59:35: error: expected ',' or '...' before '(' token
MemoryPool g_messagePool((size_t)(sizeof(XbusMessage)), NULL);
^
.....
I don't understand what I'm doing wrong. The source is compiled using the C++ compiler, Eclipse can find the constructor,... What am I doing wrong?
Any suggestions? I could use the standard c interface, but I don't like giving up because of a non-understood compiler error.
edit:
I also get the error:
Code: Select all
'((XbusThread*)this)->XbusThread::g_messageDataPool' does not have class type xbus_thread.hpp /RT-STM32F303R8-SensorSlave/Xsens/Inc line 80 C/C++ Problem
Apparently the g_messageDataPool is not seen as a class, but as another type, I guess it is compiled as a `MemoryPool` struct, from the C library (http://chibios.sourceforge.net/html/struct_memory_pool.html). How do I tell the compiler that I want to call the constructor from the C++ library?