Skip to content

Commit a134dc1

Browse files
committed
Move to use C++20 as standard.
Remove non-functional compiler-flag test. Remove a contraction in an explanatory text so vim will highlight correctly. Always add -Wextra compiler flag. We are now completely warning free. Add configure option --enable-werror to force any warnings to become errors.
1 parent 21fe47f commit a134dc1

2 files changed

Lines changed: 33 additions & 11 deletions

File tree

src/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,6 @@ OPT := -Os $(INTEGER_OVERFLOW_FLAGS)
255255
DEBUG := $(DEBUG) -g -Wall -D_FORTIFY_SOURCE=2
256256
CFLAGS := $(INCLUDE) $(OPT) $(DEBUG) -DULAPI -std=gnu11 -Werror=implicit-function-declaration $(CFLAGS) $(CPPFLAGS) $(EXTRA_DEBUG)
257257
CXXFLAGS := $(INCLUDE) $(OPT) $(DEBUG) -DULAPI -Werror=overloaded-virtual $(CXXFLAGS) $(CPPFLAGS) $(EXTRA_DEBUG)
258-
CXXFLAGS += -std=gnu++20
259258
# In Debian 11, any inclusion of <boost/python.hpp> leads to several
260259
# diagnostics from included headers about deprecated features. LinuxCNC does
261260
# not directly use these deprecated features, but it does use boost::python.

src/configure.ac

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ m4_include([m4/ax_python.m4])
3939
m4_include([m4/ax_python_devel.m4])
4040
m4_include([m4/ax_boost_base.m4])
4141
m4_include([m4/ax_boost_python.m4])
42-
AX_CXX_COMPILE_STDCXX(17, , mandatory)
42+
AX_CXX_COMPILE_STDCXX(20, , mandatory)
4343

4444
AC_MSG_CHECKING(build toplevel)
4545
BUILD_TOPLEVEL="$(cd ..; pwd -P)"
@@ -406,14 +406,6 @@ elif ! test `$CC -dumpversion | cut -d '.' -f 1` -gt 2 ; then
406406
AC_MSG_ERROR([Compilers older than gcc 3.x are no longer supported])
407407
fi
408408

409-
# Set flags for C and C++ if supported
410-
for commonflag in -Wno-stringop-truncation ; do
411-
if echo "int main() { return 0;}" | $CC -Werror $commonflag -E - > /dev/null; then
412-
CFLAGS="${CFLAGS:+$CFLAGS }$flag"
413-
CXXFLAGS="${CXXFLAGS:+$CXXFLAGS }$flag"
414-
fi
415-
done
416-
417409
AC_MSG_CHECKING([for usability of linux/hidraw.h])
418410
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
419411
#include <sys/ioctl.h>
@@ -1559,7 +1551,7 @@ AC_SUBST([READLINE_LIBS])
15591551
# if you don't have nls tools, allow a way out!
15601552

15611553
AC_ARG_ENABLE(nls,
1562-
AS_HELP_STRING([--disable-nls], [Don't use NLS.]),
1554+
AS_HELP_STRING([--disable-nls], [Do not use NLS.]),
15631555
USE_NLS=no, USE_NLS=yes)
15641556
AC_SUBST(USE_NLS)
15651557

@@ -1670,6 +1662,37 @@ AC_CHECK_HEADERS(X11/Xmu/Xmu.h,[],[AC_MSG_ERROR([Required Xmu header missing. I
16701662
AC_SUBST([LIBPYTHON])
16711663
AC_SUBST([SITEPY])
16721664

1665+
#
1666+
# Add extra options to CFLAGS and CXXFLAGS
1667+
#
1668+
add_to_cflags() {
1669+
# Add $1 to CFLAGS and CXXFLAGS if not already there
1670+
if test -z "$1"; then return; fi
1671+
if echo "$CFLAGS" | grep -q -w -v -- "$1"; then
1672+
CFLAGS="${CFLAGS:+$CFLAGS }$1"
1673+
fi
1674+
if echo "$CXXFLAGS" | grep -q -w -v -- "$1"; then
1675+
CXXFLAGS="${CXXFLAGS:+$CXXFLAGS }$1"
1676+
fi
1677+
}
1678+
1679+
# Always add -Wextra
1680+
add_to_cflags "-Wextra"
1681+
1682+
# The last thing before subst-exporting CFLAGS and CXXFLAGS is to add -Werror
1683+
# if requested. Doing it earlier causes conf-tests to fail that are supposed to
1684+
# succeed when they generate warnings.
1685+
AC_ARG_ENABLE(werror,
1686+
AS_HELP_STRING(
1687+
[--enable-werror],
1688+
[Treat all compiler warnings as errors (-Werror).],
1689+
),
1690+
[
1691+
case "$enableval" in
1692+
(yes) add_to_cflags "-Werror" ;;
1693+
esac
1694+
])
1695+
16731696
AC_SUBST([CFLAGS])
16741697
AC_SUBST([CPPFLAGS])
16751698
AC_SUBST([CXXFLAGS])

0 commit comments

Comments
 (0)