diff --git a/make/common-defs.mk b/make/common-defs.mk index 88b1ce806..d7383e703 100644 --- a/make/common-defs.mk +++ b/make/common-defs.mk @@ -155,13 +155,13 @@ endif CDEFS += $(BOARD_CDEFS) ifeq ($(DEBUG), YES) - CFLAGS += -DDEBUG + CPPFLAGS += -DDEBUG else CFLAGS += -fdata-sections -ffunction-sections endif ifeq ($(USE_CXX), YES) - CFLAGS += -DPIOS_ENABLE_CXX + CPPFLAGS += -DPIOS_ENABLE_CXX endif @@ -172,8 +172,12 @@ CFLAGS += -MD -MP -MF $(OUTDIR)/dep/$(@F).d #CONLYFLAGS += -Wnested-externs CONLYFLAGS += $(CSTANDARD) -Wunsuffixed-float-constants -# CPP Flags -CPPFLAGS += -fno-rtti -fno-exceptions -std=c++11 -fno-use-cxa-atexit +# C++ Flags +# Note C++ compilation also uses CFLAGS. CONLYFLAGS has exclusions that +# can not be used with C++ compiler. C++ specific compile options are +# as set in CXXFLAGS. Note CPPFLAGS is for C pre-process and has not been +# used correctly - longer term move CDEFS to CPPFLAGS. +CXXFLAGS += -fno-rtti -fno-exceptions -std=c++11 -fno-use-cxa-atexit # Assembler flags. # -Wa,...: tell GCC to pass this to the assembler. diff --git a/make/firmware-defs.mk b/make/firmware-defs.mk index a464b02e9..5058f68ca 100644 --- a/make/firmware-defs.mk +++ b/make/firmware-defs.mk @@ -168,14 +168,14 @@ endef define COMPILE_C_TEMPLATE $(OUTDIR)/$(notdir $(basename $(1))).o : $(1) @$(ECHO) $(MSG_COMPILING) $$(call toprel, $$<) - $(V1) $(CC) -c $(THUMB) $$(CFLAGS) $$(CONLYFLAGS) $$< -o $$@ + $(V1) $(CC) -c $(THUMB) $$(CFLAGS) $$(CONLYFLAGS) $$(CPPFLAGS) $$< -o $$@ endef # Compile: create object files from C source files. ARM-only define COMPILE_C_ARM_TEMPLATE $(OUTDIR)/$(notdir $(basename $(1))).o : $(1) @$(ECHO) $(MSG_COMPILING_ARM) $$(call toprel, $$<) - $(V1) $(CC) -c $$(CFLAGS) $$(CONLYFLAGS) $$< -o $$@ + $(V1) $(CC) -c $$(CFLAGS) $$(CONLYFLAGS) $$(CPPFLAGS) $$< -o $$@ endef # Compile: create object files from C++ source files. @@ -225,7 +225,7 @@ define LINK_TEMPLATE .PRECIOUS : $(2) $(3) $(1): $(2) $(3) @$(ECHO) $(MSG_LINKING) $$(call toprel, $$@) - $(V1) $(CC) $(THUMB) $$(CFLAGS) $(2) $(3) --output $$@ $$(LDFLAGS) + $(V1) $(CC) $(THUMB) $$(CFLAGS) $$(CPPFLAGS) $(2) $(3) --output $$@ $$(LDFLAGS) endef # Link: create ELF output file from object files.