Skip to content

Commit 1cf1264

Browse files
committed
Moved to C++20
1 parent eb86c2e commit 1cf1264

File tree

12 files changed

+59
-46
lines changed

12 files changed

+59
-46
lines changed

firmware-template-bcm/Rules.mk

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ $(BUILD)$1/%.o: $(SOURCE)$1/%.c
9090
$(CC) $(COPS) -c $$< -o $$@
9191

9292
$(BUILD)$1/%.o: $(SOURCE)$1/%.cpp
93-
$(CPP) -pedantic -fno-exceptions -fno-unwind-tables -fno-rtti -fno-threadsafe-statics -std=c++11 $(COPS) -c $$< -o $$@
93+
$(CPP) -pedantic -fno-exceptions -fno-unwind-tables -fno-rtti -fno-threadsafe-statics -std=c++14 $(COPS) -c $$< -o $$@
9494
endef
9595

9696
define compile-objects7

firmware-template-bcm/lib/Rules.mk

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ $(BUILD)$1/%.o: $1/%.c
6767
$(CC) $(COPS) -c $$< -o $$@
6868

6969
$(BUILD)$1/%.o: $1/%.cpp
70-
$(CPP) $(COPS) -pedantic -fno-exceptions -fno-unwind-tables -fno-rtti -fno-threadsafe-statics -std=c++11 -c $$< -o $$@
70+
$(CPP) $(COPS) -pedantic -fno-exceptions -fno-unwind-tables -fno-rtti -fno-threadsafe-statics -std=c++14 -c $$< -o $$@
7171

7272
$(BUILD)$1/%.o: $1/%.S
7373
$(CC) $(COPS) -D__ASSEMBLY__ -c $$< -o $$@
@@ -78,7 +78,7 @@ $(BUILD7)$1/%.o: $1/%.c
7878
$(CC) $(COPS7) -c $$< -o $$@
7979

8080
$(BUILD7)$1/%.o: $1/%.cpp
81-
$(CPP) $(COPS7) -pedantic -fno-exceptions -fno-unwind-tables -fno-rtti -fno-threadsafe-statics -std=c++11 -c $$< -o $$@
81+
$(CPP) $(COPS7) -pedantic -fno-exceptions -fno-unwind-tables -fno-rtti -fno-threadsafe-statics -std=c++14 -c $$< -o $$@
8282

8383
$(BUILD7)$1/%.o: $1/%.S
8484
$(CC) $(COPS7) -D__ASSEMBLY__ -c $$< -o $$@

firmware-template-h3/Rules.mk

+5-4
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,10 @@ endif
5454

5555
DEFINES+=-DBARE_METAL -DH3
5656
DEFINES+=-DPHY_TYPE=PHY_GENERIC
57-
DEFINES+=-DENABLE_TFTP_SERVER -D__FPU_PRESENT=1
57+
DEFINES+=-DENABLE_TFTP_SERVER
5858
DEFINES+=-DCONFIG_MDNS_DOMAIN_REVERSE
5959
DEFINES+=-DISABLE_INTERNAL_RTC
60+
DEFINES+=-D__FPU_PRESENT=1 -D__GIC_PRESENT=1
6061

6162
ifneq ($(findstring CONFIG_STORE_USE_SPI,$(DEFINES)), CONFIG_STORE_USE_SPI)
6263
DEFINES+=-DCONFIG_STORE_USE_SPI
@@ -69,7 +70,7 @@ ifeq ($(findstring ARTNET_VERSION=4,$(DEFINES)),ARTNET_VERSION=4)
6970
endif
7071

7172
# The variable for the firmware include directories
72-
INCDIRS+=../include $(wildcard ./include) $(wildcard ./*/include) ../firmware-template-h3/include
73+
INCDIRS+=../include $(wildcard ./include) $(wildcard ./*/include) ../firmware-template-h3/include ../lib-h3/CMSIS/Core_A/Include
7374
INCDIRS:=$(addprefix -I,$(INCDIRS))
7475

7576
# The variable for the libraries include directory
@@ -93,10 +94,10 @@ COPS+=$(INCDIRS) $(LIBINCDIRS) $(addprefix -I,$(EXTRA_INCLUDES))
9394
COPS+=-mfpu=neon-vfpv4 -mcpu=cortex-a7 -mfloat-abi=hard -mhard-float
9495
COPS+=-nostartfiles -ffreestanding -nostdlib -fprefetch-loop-arrays
9596
COPS+=-O2 -Wall -Werror -Wpedantic -Wextra -Wunused -Wsign-conversion -Wconversion
96-
COPS+=-Wduplicated-cond -Wlogical-op #-Wduplicated-branches
97+
COPS+=-Wduplicated-cond -Wlogical-op -Wduplicated-branches
9798
COPS+=-ffunction-sections -fdata-sections
9899

99-
CPPOPS=-std=c++11 -Wuseless-cast -Wold-style-cast -Wnon-virtual-dtor -Woverloaded-virtual -Wnull-dereference -fno-rtti -fno-exceptions -fno-unwind-tables
100+
CPPOPS=-std=c++20 -Wuseless-cast -Wold-style-cast -Wnon-virtual-dtor -Woverloaded-virtual -Wnull-dereference -fno-rtti -fno-exceptions -fno-unwind-tables
100101
CPPOPS+=-fno-threadsafe-statics
101102

102103
LDOPS=--gc-sections --print-gc-sections

firmware-template-h3/lib/Rules.mk

+5-4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ SRCDIR+=src/debug
2626
$(info [${SRCDIR}])
2727

2828
INCLUDES:=-I./include -I../include -I../lib-device/include -I../lib-flash/include -I../lib-configstore/include -I../lib-hal/include -I../lib-debug/include -I../lib-h3/include -I../lib-arm/include
29+
INCLUDES+=-I../lib-h3/CMSIS/Core_A/Include
2930
INCLUDES+=$(addprefix -I,$(EXTRA_INCLUDES))
3031

3132
DEFINES:=-D$(PLATFORM) $(addprefix -D,$(DISPLAYS)) $(addprefix -D,$(DEFINES))
@@ -35,9 +36,10 @@ ifneq ($(findstring _TIME_STAMP_YEAR_,$(DEFINES)), _TIME_STAMP_YEAR_)
3536
endif
3637

3738
DEFINES+=-DPHY_TYPE=PHY_GENERIC
38-
DEFINES+=-DENABLE_TFTP_SERVER -D__FPU_PRESENT=1
39+
DEFINES+=-DENABLE_TFTP_SERVER
3940
DEFINES+=-DCONFIG_MDNS_DOMAIN_REVERSE
4041
DEFINES+=-DISABLE_INTERNAL_RTC
42+
DEFINES+=-D__FPU_PRESENT=1 -D__GIC_PRESENT=1
4143

4244
ifneq ($(findstring CONFIG_STORE_USE_SPI,$(DEFINES)), CONFIG_STORE_USE_SPI)
4345
DEFINES+=-DCONFIG_STORE_USE_SPI
@@ -66,12 +68,11 @@ $(info $$MAKE_FLAGS [${MAKE_FLAGS}])
6668
COPS=-DBARE_METAL -DH3 $(DEFINES) $(MAKE_FLAGS) $(INCLUDES)
6769
COPS+=-mfpu=neon-vfpv4 -mcpu=cortex-a7 -mfloat-abi=hard -mhard-float
6870
COPS+=-nostartfiles -ffreestanding -nostdlib -fprefetch-loop-arrays
69-
#COPS+=-ftree-vectorize -fdump-tree-vect-details
7071
COPS+=-O2 -Wall -Werror -Wextra -Wpedantic -Wunused -Wsign-conversion -Wconversion
71-
COPS+=-Wduplicated-cond -Wlogical-op #-Wduplicated-branches
72+
COPS+=-Wduplicated-cond -Wlogical-op -Wduplicated-branches
7273
COPS+=-ffunction-sections -fdata-sections
7374

74-
CPPOPS=-std=c++11 -Wuseless-cast -Wold-style-cast -Wnon-virtual-dtor -Woverloaded-virtual -Wnull-dereference -fno-rtti -fno-exceptions -fno-unwind-tables
75+
CPPOPS=-std=c++20 -Wuseless-cast -Wold-style-cast -Wnon-virtual-dtor -Woverloaded-virtual -Wnull-dereference -fno-rtti -fno-exceptions -fno-unwind-tables
7576
CPPOPS+=-fno-threadsafe-statics
7677

7778
CURR_DIR:=$(notdir $(patsubst %/,%,$(CURDIR)))

firmware-template-linux/Rules.mk

+1-6
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,7 @@ else
101101
COPS+=-Wduplicated-cond -Wlogical-op #-Wduplicated-branches
102102
# CCPOPS+=-Wuseless-cast -Wold-style-cast
103103
endif
104-
105-
ifeq ($(detected_OS),Cygwin)
106-
CCPOPS+=-std=gnu++11
107-
else
108-
CCPOPS+=-std=c++11
109-
endif
104+
CCPOPS+=-std=c++20
110105

111106
COPS+=-ffunction-sections -fdata-sections
112107

firmware-template-linux/lib/Rules.mk

+2-7
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ DEFINES+=-DDISABLE_TFTP
1717
DEFINES+=-DENABLE_HTTPD
1818
DEFINES+=-DCONFIG_STORE_USE_FILE
1919
DEFINES+=-DCONFIG_MDNS_DOMAIN_REVERSE
20-
DEFINES+=-DISABLE_INTERNAL_RTC
20+
DEFINES+=-DDISABLE_INTERNAL_RTC
2121

2222
ifeq ($(findstring ARTNET_VERSION=4,$(DEFINES)),ARTNET_VERSION=4)
2323
ifeq ($(findstring ARTNET_HAVE_DMXIN,$(DEFINES)),ARTNET_HAVE_DMXIN)
@@ -70,12 +70,7 @@ else
7070
endif
7171

7272
CCPOPS=-fno-rtti -fno-exceptions -fno-unwind-tables -Wnon-virtual-dtor
73-
74-
ifeq ($(detected_OS),Cygwin)
75-
CCPOPS+=-std=gnu++11
76-
else
77-
CCPOPS+=-std=c++11
78-
endif
73+
CCPOPS+=-std=c++20
7974

8075
COPS+=-ffunction-sections -fdata-sections
8176

firmware-template/libs.mk

+21-13
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@ $(info $$DEFINES [${DEFINES}])
22

33
ifeq ($(findstring NO_EMAC,$(DEFINES)),NO_EMAC)
44
else
5-
LIBS+=remoteconfig
5+
ifeq ($(findstring CONFIG_NETWORK_USE_MINIMUM,$(DEFINES)),CONFIG_NETWORK_USE_MINIMUM)
6+
else
7+
LIBS+=remoteconfig
8+
endif
69
endif
710

811
ifeq ($(findstring NODE_NODE,$(DEFINES)),NODE_NODE)
@@ -24,6 +27,12 @@ ifeq ($(findstring NODE_E131,$(DEFINES)),NODE_E131)
2427
endif
2528
endif
2629

30+
ifeq ($(findstring E131_CONTROLLER,$(DEFINES)),E131_CONTROLLER)
31+
ifneq ($(findstring e131,$(LIBS)),e131)
32+
LIBS+=e131
33+
endif
34+
endif
35+
2736
ifeq ($(findstring NODE_SHOWFILE,$(DEFINES)),NODE_SHOWFILE)
2837
LIBS+=showfile osc
2938
endif
@@ -55,12 +64,12 @@ ifeq ($(findstring ARTNET_CONTROLLER,$(DEFINES)),ARTNET_CONTROLLER)
5564
endif
5665

5766
ifeq ($(findstring RDM_CONTROLLER,$(DEFINES)),RDM_CONTROLLER)
58-
LIBS+=rdm
67+
RDM=1
5968
DMX=1
6069
endif
6170

6271
ifeq ($(findstring RDM_RESPONDER,$(DEFINES)),RDM_RESPONDER)
63-
LIBS+=rdm
72+
RDM=1
6473
ifneq ($(findstring NODE_ARTNET,$(DEFINES)),NODE_ARTNET)
6574
ifneq ($(findstring dmxreceiver,$(LIBS)),dmxreceiver)
6675
LIBS+=dmxreceiver
@@ -82,12 +91,7 @@ ifeq ($(findstring NODE_DMX,$(DEFINES)),NODE_DMX)
8291
endif
8392

8493
ifeq ($(findstring NODE_RDMNET_LLRP_ONLY,$(DEFINES)),NODE_RDMNET_LLRP_ONLY)
85-
ifneq ($(findstring RDM_CONTROLLER,$(DEFINES)),RDM_CONTROLLER)
86-
LIBS+=rdm
87-
endif
88-
ifneq ($(findstring rdmnet,$(LIBS)),rdmnet)
89-
LIBS+=rdmnet
90-
endif
94+
RDM=1
9195
ifneq ($(findstring e131,$(LIBS)),e131)
9296
LIBS+=e131
9397
endif
@@ -99,10 +103,6 @@ ifeq ($(findstring NODE_RDMNET_LLRP_ONLY,$(DEFINES)),NODE_RDMNET_LLRP_ONLY)
99103
endif
100104
endif
101105

102-
ifeq ($(findstring e131,$(LIBS)),e131)
103-
LIBS+=uuid
104-
endif
105-
106106
ifeq ($(findstring OUTPUT_DMX_MONITOR,$(DEFINES)),OUTPUT_DMX_MONITOR)
107107
LIBS+=dmxmonitor
108108
endif
@@ -112,10 +112,18 @@ ifeq ($(findstring OUTPUT_DMX_SEND,$(DEFINES)),OUTPUT_DMX_SEND)
112112
DMX=1
113113
endif
114114

115+
ifdef RDM
116+
LIBS+=rdm
117+
endif
118+
115119
ifdef DMX
116120
LIBS+=dmx
117121
endif
118122

123+
ifeq ($(findstring e131,$(LIBS)),e131)
124+
LIBS+=uuid
125+
endif
126+
119127
ifeq ($(findstring OUTPUT_DDP_PIXEL_MULTI,$(DEFINES)),OUTPUT_DDP_PIXEL_MULTI)
120128
LIBS+=ws28xxdmx ws28xx jamstapl
121129
else

lib-c++/.settings/language.settings.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
66
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
77
<provider copy-of="extension" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser"/>
8-
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-1522357966463138799" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
8+
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="952649484323753915" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
99
<language-scope id="org.eclipse.cdt.core.gcc"/>
1010
<language-scope id="org.eclipse.cdt.core.g++"/>
1111
</provider>
@@ -17,7 +17,7 @@
1717
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
1818
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
1919
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuildCommandParser" id="org.eclipse.cdt.managedbuilder.core.GCCBuildCommandParser" keep-relative-paths="false" name="CDT GCC Build Output Parser" parameter="([^/\\\\]*)((g?cc)|([gc]\+\+)|(clang))" prefer-non-shared="true"/>
20-
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-1522357966463138799" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
20+
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="952649484323753915" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">
2121
<language-scope id="org.eclipse.cdt.core.gcc"/>
2222
<language-scope id="org.eclipse.cdt.core.g++"/>
2323
</provider>

lib-c++/src/delete.cpp

+15-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @file delete.cpp
33
*
44
*/
5-
/* Copyright (C) 2017-2020 by Arjan van Vught mailto:info@orangepi-dmx.nl
5+
/* Copyright (C) 2017-2024 by Arjan van Vught mailto:info@info@gd32-dmx.org
66
*
77
* Permission is hereby granted, free of charge, to any person obtaining a copy
88
* of this software and associated documentation files (the "Software"), to deal
@@ -23,7 +23,8 @@
2323
* THE SOFTWARE.
2424
*/
2525

26-
#include <stdlib.h>
26+
#include <cstdlib>
27+
#include <cstddef>
2728

2829
void operator delete(void *p) {
2930
free(p);
@@ -32,3 +33,15 @@ void operator delete(void *p) {
3233
void operator delete[](void *p) {
3334
free(p);
3435
}
36+
37+
/*
38+
* C++14 and above
39+
*/
40+
41+
void operator delete(void *p, [[maybe_unused]] std::size_t size) noexcept {
42+
free(p);
43+
}
44+
45+
void operator delete[](void *p, [[maybe_unused]]std::size_t size) noexcept {
46+
free(p);
47+
}

lib-c++/src/dso_handle.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @file dso_handle.cpp
33
*
44
*/
5-
/* Copyright (C) 2023 by Arjan van Vught mailto:info@orangepi-dmx.nl
5+
/* Copyright (C) 2023 by Arjan van Vught mailto:info@info@gd32-dmx.org
66
*
77
* Permission is hereby granted, free of charge, to any person obtaining a copy
88
* of this software and associated documentation files (the "Software"), to deal
@@ -23,7 +23,7 @@
2323
* THE SOFTWARE.
2424
*/
2525

26-
extern "C" int __aeabi_atexit(void *object, void (*destructor)(void*), void *dso_handle) {
26+
extern "C" int __aeabi_atexit(void *object, void (*destructor)(void *), void *dso_handle) {
2727
static_cast<void>(object);
2828
static_cast<void>(destructor);
2929
static_cast<void>(dso_handle);

lib-c++/src/new.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @file new.cpp
33
*
44
*/
5-
/* Copyright (C) 2017-2020 by Arjan van Vught mailto:info@orangepi-dmx.nl
5+
/* Copyright (C) 2017-2024 by Arjan van Vught mailto:info@gd32-dmx.org
66
*
77
* Permission is hereby granted, free of charge, to any person obtaining a copy
88
* of this software and associated documentation files (the "Software"), to deal
@@ -23,7 +23,7 @@
2323
* THE SOFTWARE.
2424
*/
2525

26-
#include <stdlib.h>
26+
#include <cstdlib>
2727

2828
void *operator new(unsigned size) {
2929
return malloc(size);

lib-c++/src/purecall.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @file purecall.cpp
33
*
44
*/
5-
/* Copyright (C) 2017-2020 by Arjan van Vught mailto:info@orangepi-dmx.nl
5+
/* Copyright (C) 2017-2024 by Arjan van Vught mailto:info@gd32-dmx.org
66
*
77
* Permission is hereby granted, free of charge, to any person obtaining a copy
88
* of this software and associated documentation files (the "Software"), to deal

0 commit comments

Comments
 (0)