This forum is dedicated to feedback, discussions about ongoing or future developments, ideas and suggestions regarding the ChibiOS projects are welcome. This forum is NOT for support.
I tried using C++ with a basic Chibios project. I therefore renamed main.c to main.cpp and moved it to CPPSRC in the makefile. I thought that should work but i get a
I made some tests, that section is for exception handling, just add -fno-exceptions to the makefile:
USE_CPPOPT = -fno-rtti -fno-exceptions
Supporting exceptions would require more changes but I would not recommend exceptions in an embedded application anyway because the code size would explode. If you want to support exceptions change the file ch.ld as follow:
/* ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, 2011 Giovanni Di Sirio.
This file is part of ChibiOS/RT.
ChibiOS/RT is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.
ChibiOS/RT is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */
I try to add a simple cpp file (Debug.cpp) in my STM32 project (composed by test.c file). I have the following error. The pb comes probably from the makeFile/compiler (see below). Does anyone have an idea ?
arm-none-eabi-gcc -c -mcpu=cortex-m3 -O2 -ggdb -fomit-frame-pointer -falign-functions=16 -ffunction-sections -fdata-sections -Wall -Wextra -Wstrict-prototypes -std=c99 -Wa,-alms=test.lst -DTHUMB_PRESENT -mno-thumb-interwork -DTHUMB_NO_INTERWORKING -MD -MP -MF .dep/test.o.d -mthumb -DTHUMB -I . -I../../os/ports/GCC/ARMCMx -I../../os/ports/GCC/ARMCMx/STM32 -I../../os/kernel/include -I../../os/hal/include -I../../os/hal/platforms/STM32 -I../../boards/MULTIPILOT32 -I../../os/various test.c -o test.o In file included from test.c:5:0: Debug.h:12:1: error: unknown type name 'class' Debug.h:13:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token Debug.h:22:1: error: unknown type name 'Debug_Class'
# # Build global options ##############################################################################
############################################################################## # Architecture or project specific options #
# Enable this if you really want to use the STM FWLib. ifeq ($(USE_FWLIB),) USE_FWLIB = no endif
# # Architecture or project specific options ##############################################################################
############################################################################## # Project, sources and paths #
# Define project name here PROJECT = MP32TESTPROGRAM
# Define linker script file here LDSCRIPT= ch.ld
# Imported source files CHIBIOS = ../.. include $(CHIBIOS)/boards/MULTIPILOT32/board.mk include $(CHIBIOS)/os/hal/platforms/STM32/platform.mk include $(CHIBIOS)/os/hal/hal.mk include $(CHIBIOS)/os/ports/GCC/ARMCMx/STM32/port.mk include $(CHIBIOS)/os/kernel/kernel.mk # include $(CHIBIOS)/test/test.mk
# C sources that can be compiled in ARM or THUMB mode depending on the global # setting. CSRC = $(PORTSRC) \ $(KERNSRC) \ $(TESTSRC) \ $(HALSRC) \ $(PLATFORMSRC) \ $(BOARDSRC) \ $(CHIBIOS)/os/various/evtimer.c \ $(CHIBIOS)/os/various/syscalls.c \ test.c
# C++ sources that can be compiled in ARM or THUMB mode depending on the global # setting. CPPSRC =
# C sources to be compiled in ARM mode regardless of the global setting. # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler # option that results in lower performance and larger code size. ACSRC =
# C++ sources to be compiled in ARM mode regardless of the global setting. # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler # option that results in lower performance and larger code size. ACPPSRC =
# C sources to be compiled in THUMB mode regardless of the global setting. # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler # option that results in lower performance and larger code size. TCSRC =
# C sources to be compiled in THUMB mode regardless of the global setting. # NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler # option that results in lower performance and larger code size. TCPPSRC =
#TRGT = arm-elf- TRGT = arm-none-eabi- CC = $(TRGT)gcc CPPC = $(TRGT)g++ # Enable loading with g++ only if you need C++ runtime support. # NOTE: You can use C++ even without C++ support if you are careful. C++ # runtime support makes code size explode. LD = $(TRGT)gcc LD = $(TRGT)g++ CP = $(TRGT)objcopy AS = $(TRGT)gcc -x assembler-with-cpp OD = $(TRGT)objdump HEX = $(CP) -O ihex BIN = $(CP) -O binary
# ARM-specific options here AOPT =
# THUMB-specific options here TOPT = -mthumb -DTHUMB
# Define C warning options here CWARN = -Wall -Wextra -Wstrict-prototypes -std=c99
# Define C++ warning options here CPPWARN = -Wall -Wextra -std=c99
Hi Cyrille - looks like you are compiling that code as C, not C++. I would recommend putting that code into test.cpp instead of test.c and then, in the Makefile, adding it to the CPPSRC group instead of the CSRC group.
I have tested your recommendation and I have the following error :
c:/programmes/yagarto/bin/../lib/gcc/arm-none-eabi/4.6.0/../../../../arm-none-eabi/bin/ld.exe: error: no memory region specified for loadable section `.ARM.extab' collect2: ld returned 1 exit status