From 267c8e1620c61392cd14435154dd19f524529327 Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Thu, 9 Jul 2020 21:15:38 +0200 Subject: [PATCH] Makefile.include: Link with $(CXX) for C++ code When mixing C and C++ code, $(CXX) has to be used for linking. Prior to this commit, the build system automatically uses $(CXX) if the application contains C++ source code. However, if C++ is used in an module only, $(CC) is still used. This has not let to problems, as internal modules must be written in C. For external modules this restriction does not apply. This commit checks if the cpp feature is used. In that case, $(CXX) is used for linking over $(CC). This way external modules may use C++ code. --- Makefile.include | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile.include b/Makefile.include index 59807b747e..be6f27a580 100644 --- a/Makefile.include +++ b/Makefile.include @@ -536,7 +536,9 @@ else endif # variables used to compile and link c++ -CPPMIX ?= $(if $(wildcard *.cpp),1,) +ifneq (,$(filter cpp,$(FEATURES_USED))) + CPPMIX ?= 1 +endif # We assume $(LINK) to be gcc-like. Use `LINKFLAGPREFIX :=` for ld-like linker options. LINKFLAGPREFIX ?= -Wl,