Skip to content

Commit

Permalink
Merge pull request #3326 from BsAtHome/fix_cxx-standard-20
Browse files Browse the repository at this point in the history
Use C++20 as compile standard
  • Loading branch information
andypugh authored Feb 6, 2025
2 parents 8979fc6 + 8ba2ee3 commit cf4976f
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ jobs:
runs-on: ubuntu-24.04
strategy:
matrix:
image: ["debian:bullseye", "debian:bookworm", "debian:sid"]
image: ["debian:bookworm", "debian:sid"]
container:
image: ${{ matrix.image }}
# IPC_OWNER is needed for shmget IPC_CREAT
Expand Down Expand Up @@ -176,7 +176,7 @@ jobs:
runs-on: ubuntu-24.04
strategy:
matrix:
image: ["debian:bullseye", "debian:bookworm", "debian:sid"]
image: ["debian:bookworm", "debian:sid"]
container:
image: ${{ matrix.image }}
# IPC_OWNER is needed for shmget IPC_CREAT
Expand Down
1 change: 0 additions & 1 deletion src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@ OPT := -Os $(INTEGER_OVERFLOW_FLAGS)
DEBUG := $(DEBUG) -g -Wall -D_FORTIFY_SOURCE=2
CFLAGS := $(INCLUDE) $(OPT) $(DEBUG) -DULAPI -std=gnu11 -Werror=implicit-function-declaration $(CFLAGS) $(CPPFLAGS) $(EXTRA_DEBUG)
CXXFLAGS := $(INCLUDE) $(OPT) $(DEBUG) -DULAPI -Werror=overloaded-virtual $(CXXFLAGS) $(CPPFLAGS) $(EXTRA_DEBUG)
CXXFLAGS += -std=gnu++20
# In Debian 11, any inclusion of <boost/python.hpp> leads to several
# diagnostics from included headers about deprecated features. LinuxCNC does
# not directly use these deprecated features, but it does use boost::python.
Expand Down
43 changes: 33 additions & 10 deletions src/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ m4_include([m4/ax_python.m4])
m4_include([m4/ax_python_devel.m4])
m4_include([m4/ax_boost_base.m4])
m4_include([m4/ax_boost_python.m4])
AX_CXX_COMPILE_STDCXX(17, , mandatory)
AX_CXX_COMPILE_STDCXX(20, , mandatory)

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

# Set flags for C and C++ if supported
for commonflag in -Wno-stringop-truncation ; do
if echo "int main() { return 0;}" | $CC -Werror $commonflag -E - > /dev/null; then
CFLAGS="${CFLAGS:+$CFLAGS }$flag"
CXXFLAGS="${CXXFLAGS:+$CXXFLAGS }$flag"
fi
done

AC_MSG_CHECKING([for usability of linux/hidraw.h])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <sys/ioctl.h>
Expand Down Expand Up @@ -1559,7 +1551,7 @@ AC_SUBST([READLINE_LIBS])
# if you don't have nls tools, allow a way out!

AC_ARG_ENABLE(nls,
AS_HELP_STRING([--disable-nls], [Don't use NLS.]),
AS_HELP_STRING([--disable-nls], [Do not use NLS.]),
USE_NLS=no, USE_NLS=yes)
AC_SUBST(USE_NLS)

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

#
# Add extra options to CFLAGS and CXXFLAGS
#
add_to_cflags() {
# Add $1 to CFLAGS and CXXFLAGS if not already there
if test -z "$1"; then return; fi
if echo "$CFLAGS" | grep -q -w -v -- "$1"; then
CFLAGS="${CFLAGS:+$CFLAGS }$1"
fi
if echo "$CXXFLAGS" | grep -q -w -v -- "$1"; then
CXXFLAGS="${CXXFLAGS:+$CXXFLAGS }$1"
fi
}

# Always add -Wextra
add_to_cflags "-Wextra"

# The last thing before subst-exporting CFLAGS and CXXFLAGS is to add -Werror
# if requested. Doing it earlier causes conf-tests to fail that are supposed to
# succeed when they generate warnings.
AC_ARG_ENABLE(werror,
AS_HELP_STRING(
[--enable-werror],
[Treat all compiler warnings as errors (-Werror).],
),
[
case "$enableval" in
(yes) add_to_cflags "-Werror" ;;
esac
])

AC_SUBST([CFLAGS])
AC_SUBST([CPPFLAGS])
AC_SUBST([CXXFLAGS])
Expand Down

0 comments on commit cf4976f

Please sign in to comment.