Skip to content

Commit ff5e489

Browse files
authored
Merge pull request #1953 from jepler/bump-gcc-std
Bump the C/C++ language standards version
2 parents e1de97d + 456b6d4 commit ff5e489

File tree

9 files changed

+1102
-151
lines changed

9 files changed

+1102
-151
lines changed

src/Makefile

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -244,18 +244,16 @@ INCLUDE += $(LIBTIRPC_CFLAGS)
244244
# Compilation options. Perhaps some of these should come from Makefile.inc? (CXXFLAGS now does)
245245
INTEGER_OVERFLOW_FLAGS := -fwrapv
246246
OPT := -Os $(INTEGER_OVERFLOW_FLAGS)
247-
DEBUG := $(DEBUG) -g -Wall -Wno-stringop-truncation
248-
CFLAGS := $(INCLUDE) $(OPT) $(DEBUG) $(EXTRA_DEBUG) -DULAPI -std=gnu99 -fgnu89-inline -Werror=implicit-function-declaration $(CFLAGS) $(CPPFLAGS)
249-
CXXFLAGS := $(INCLUDE) $(EXTRA_DEBUG) -DULAPI $(DEBUG) $(OPT) -Woverloaded-virtual $(CXXFLAGS) $(CPPFLAGS)
250-
CXXFLAGS += $(call cxx-option, -Wno-psabi)
251-
CXXFLAGS += $(call cxx-option, -std=gnu++11, -std=gnu++0x)
247+
DEBUG := $(DEBUG) -g -Wall -Wno-stringop-truncation -D_FORTIFY_SOURCE=2
248+
CFLAGS := $(INCLUDE) $(OPT) $(DEBUG) $(EXTRA_DEBUG) -DULAPI -std=gnu11 -Werror=implicit-function-declaration $(CFLAGS) $(CPPFLAGS)
249+
CXXFLAGS := $(INCLUDE) $(EXTRA_DEBUG) -DULAPI $(DEBUG) $(OPT) -Werror=overloaded-virtual $(CXXFLAGS) $(CPPFLAGS)
250+
CXXFLAGS += -std=gnu++17
252251
# In Debian 11, any inclusion of <boost/python.hpp> leads to several
253252
# diagnostics from included headers about deprecated features. LinuxCNC does
254253
# not directly use these deprecated features, but it does use boost::python.
255254
# Silence the warnings just when they occur in files using boost/python.hpp by
256255
# adding SILENCE_BOOST_INTERNAL_DIAGNOSTICS_FLAGS to the object's EXTRAFLAGS
257256
SILENCE_BOOST_INTERNAL_DIAGNOSTICS_FLAGS = -DBOOST_ALLOW_DEPRECATED_HEADERS=1 -DBOOST_BIND_GLOBAL_PLACEHOLDERS=1
258-
259257
CFLAGS += $(TOOL_NML_FLAG)
260258
CXXFLAGS += $(TOOL_NML_FLAG)
261259

@@ -878,7 +876,7 @@ EXTRA_CFLAGS := $(filter-out -ffast-math,$(RTFLAGS)) -D__MODULE__ -I$(BASEPWD)/.
878876
-I$(BASEPWD)/emc/nml_intf -I$(BASEPWD)/emc/kinematics -I$(BASEPWD)/emc/tp -I$(BASEPWD)/emc/motion \
879877
-DSEQUENTIAL_SUPPORT -DHAL_SUPPORT -DDYNAMIC_PLCSIZE -DRT_SUPPORT -DOLD_TIMERS_MONOS_SUPPORT -DMODBUS_IO_MASTER \
880878
-fno-fast-math $(call cc-option,-mieee-fp) -fno-unsafe-math-optimizations \
881-
-Wframe-larger-than=2560 -Wno-declaration-after-statement \
879+
-Werror=frame-larger-than=2560 -Wno-declaration-after-statement \
882880
$(INTEGER_OVERFLOW_FLAGS)
883881
ifneq ($(KERNELRELEASE),)
884882
ifeq ($(RTARCH):$(RTAI):$(filter $(RTFLAGS),-msse),x86_64:3:)

src/configure.ac

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,15 @@ fi
3333
AC_PROG_CXX
3434
AC_PROG_INSTALL
3535

36-
m4_include([m4/ax_cxx_compile_stdcxx_11.m4])
36+
m4_include([m4/ax_require_defined.m4])
37+
m4_include([m4/ax_cxx_compile_stdcxx.m4])
38+
m4_include([m4/ax_cxx_compile_stdcxx_17.m4])
3739
m4_include([m4/ax_python.m4])
3840
m4_include([m4/ax_python_devel.m4])
3941
m4_include([m4/ax_boost_base.m4])
4042
m4_include([m4/ax_boost_python.m4])
4143
# make this optional - it will likely only result in warnings
42-
AX_CXX_COMPILE_STDCXX_11(noext,optional)
44+
AX_CXX_COMPILE_STDCXX_17(ext,mandatory)
4345

4446
AC_MSG_CHECKING(build toplevel)
4547
BUILD_TOPLEVEL="$(cd ..; pwd -P)"

src/hal/components/carousel.comp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ FUNCTION(_){
188188
int mod_pocket = 0;
189189
int new_pos = 0;
190190
unsigned int mask;
191-
int align_pin; // used for slow align move, input depends on mode for historical reasons
191+
int align_pin = 0; // used for slow align move, input depends on mode for historical reasons
192192

193193
switch inst_code{
194194
case 'G': // Gray Code

src/hal/user_comps/sendkeys.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ void emit(int fd, int type, int code, int val)
6262
ie.type = type;
6363
ie.code = code;
6464
ie.value = val;
65-
write(fd, &ie, sizeof(ie));
65+
if (write(fd, &ie, sizeof(ie)) != sizeof(ie)) { perror("write(input_event)"); }
6666
}
6767

6868
static void exit_handler(int sig) {
@@ -219,7 +219,6 @@ int init(int argc, char* argv[]){
219219
}
220220

221221
int main(int argc, char* argv[]) {
222-
struct uinput_user_dev uidev;
223222
int i, j;
224223

225224
signal(SIGINT, exit_handler);
@@ -246,24 +245,28 @@ int main(int argc, char* argv[]) {
246245
if (! *hal->init) continue;
247246
if (*hal->init && ! param->inited) {
248247
param->fd = open("/dev/uinput", O_WRONLY | O_NONBLOCK);
249-
if (param->fd < 0) rtapi_print_msg(RTAPI_MSG_ERR,
250-
"Cannot open /dev/uinput. Suggest chmod 666 /dev/uinput\n");
248+
if (param->fd < 0) {
249+
rtapi_print_msg(RTAPI_MSG_ERR,
250+
"Cannot open /dev/uinput. Suggest chmod 666 /dev/uinput\n");
251+
abort();
252+
}
251253
ioctl(param->fd, UI_SET_EVBIT, EV_KEY);
252254
for (j = 0; j < param->num_events; j++){
253255
if (hal->event[j] > 0 && hal->event[j] < KEY_MAX){
254256
ioctl(param->fd, UI_SET_KEYBIT, hal->event[j]);
255257
rtapi_print("SET_EVBIT %i\n", hal->event[j]);
256258
}
257259
}
260+
struct uinput_user_dev uidev;
258261
memset(&uidev, 0, sizeof(uidev));
259262
strcpy(uidev.name, "linuxcnc-hal");
260263
uidev.id.bustype = BUS_USB;
261264
uidev.id.vendor = 0x1;
262265
uidev.id.product = 0x1;
263266
uidev.id.version = 1;
264267

265-
write(param->fd, &uidev, sizeof(uidev));
266-
ioctl(param->fd, UI_DEV_CREATE);
268+
if (write(param->fd, &uidev, sizeof(uidev)) != sizeof(uidev)) { perror("write(uinput_user_dev)"); abort(); }
269+
if (ioctl(param->fd, UI_DEV_CREATE) < 0) { perror("ioctl(UI_DEV_CREATE)"); abort(); }
267270
param->inited = 1;
268271
}
269272
if (*hal->keycode != param->oldcode) {

0 commit comments

Comments
 (0)