From aa7bbfc7a58bbebbd536e24195a863ca9f86a089 Mon Sep 17 00:00:00 2001 From: Arun Giridhar Date: Wed, 8 Jan 2025 15:58:09 -0500 Subject: [PATCH 1/6] contributors.in: Remove some more duplicates --- doc/interpreter/contributors.in | 2 -- 1 file changed, 2 deletions(-) diff --git a/doc/interpreter/contributors.in b/doc/interpreter/contributors.in index 9e4818acd2..af97308579 100644 --- a/doc/interpreter/contributors.in +++ b/doc/interpreter/contributors.in @@ -56,7 +56,6 @@ Avinoam Kalma Avlas Axel Mathéi Balint Reczey -Barbara Locsi Barbara Lócsi Baylis Shanks Ben Abbott @@ -533,7 +532,6 @@ Tejaswi D Prakash Tejaswi D. Prakash Teresa Twaroch Tetsuro Kurita -Tetsuro KURITA Thomas Baier Thomas D. Dean Thomas Kasper From c26df1f7530c7a165bd69b87adfd65340ef20d59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=BCtzel?= Date: Thu, 9 Jan 2025 11:43:05 +0100 Subject: [PATCH 2/6] GUI: Avoid deprecation warning with Qt 6.7 or newer. * m4/acinclude.m4 (OCTAVE_CHECK_ENUM_QT_KEY_MICRO): Add check for enumeration value "Qt::Key_micro". (OCTAVE_CHECK_QT_VERSION): Use new check. * libgui/graphics/KeyMap.cc (octave::KeyMap): Use "Qt::Key_micro" instead of "Qt::Key_mu" if possible. --- libgui/graphics/KeyMap.cc | 7 +++++++ m4/acinclude.m4 | 31 +++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/libgui/graphics/KeyMap.cc b/libgui/graphics/KeyMap.cc index 475e6f79ed..4fe40d8482 100644 --- a/libgui/graphics/KeyMap.cc +++ b/libgui/graphics/KeyMap.cc @@ -201,7 +201,14 @@ namespace KeyMap keyMapper[Qt::Key_twosuperior] = "twosuperior"; keyMapper[Qt::Key_threesuperior] = "threesuperior"; keyMapper[Qt::Key_acute] = "acute"; + // FIXME: Should the following value be changed to "micro"? The string is, + // e.g., used as the value of the field "Key" that is passed to the + // "KeyPressFcn" callback. +#if defined (HAVE_QT_KEY_MICRO) + keyMapper[Qt::Key_micro] = "mu"; +#else keyMapper[Qt::Key_mu] = "mu"; +#endif keyMapper[Qt::Key_paragraph] = "paragraph"; keyMapper[Qt::Key_periodcentered] = "periodcentered"; keyMapper[Qt::Key_cedilla] = "cedilla"; diff --git a/m4/acinclude.m4 b/m4/acinclude.m4 index 64bb21dcc5..4a057a290b 100644 --- a/m4/acinclude.m4 +++ b/m4/acinclude.m4 @@ -767,6 +767,36 @@ AC_DEFUN([OCTAVE_CHECK_FUNC_QTEXTSTREAM_SETENCODING], [ fi ]) dnl +dnl Check whether the Qt namespace contains a member Key_micro. This +dnl value was introduced in Qt 6.7. +dnl +dnl FIXME: Delete this entirely when we drop support for Qt 6.6 or older. +dnl +AC_DEFUN([OCTAVE_CHECK_ENUM_QT_KEY_MICRO], [ + AC_CACHE_CHECK([for Qt::Key_micro enum value], + [octave_cv_enum_qt_key_micro], + [AC_LANG_PUSH(C++) + ac_octave_save_CPPFLAGS="$CPPFLAGS" + ac_octave_save_CXXFLAGS="$CXXFLAGS" + CPPFLAGS="$QT_CPPFLAGS $CXXPICFLAG $CPPFLAGS" + CXXFLAGS="$CXXPICFLAG $CXXFLAGS" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #include + ]], [[ + Qt::Key key = Qt::Key_micro; + ]])], + octave_cv_enum_qt_key_micro=yes, + octave_cv_enum_qt_key_micro=no) + CPPFLAGS="$ac_octave_save_CPPFLAGS" + CXXFLAGS="$ac_octave_save_CXXFLAGS" + AC_LANG_POP(C++) + ]) + if test $octave_cv_enum_qt_key_micro = yes; then + AC_DEFINE(HAVE_QT_KEY_MICRO, 1, + [Define to 1 if you have the `Qt::Key_micro' enum value.]) + fi +]) +dnl dnl Check whether HDF5 library has version 1.6 API functions. dnl AC_DEFUN([OCTAVE_CHECK_HDF5_HAS_VER_16_API], [ @@ -2265,6 +2295,7 @@ AC_DEFUN([OCTAVE_CHECK_QT_VERSION], [AC_MSG_CHECKING([Qt version $1]) OCTAVE_CHECK_FUNC_QCOLOR_FLOAT_TYPE OCTAVE_CHECK_CLASS_QSTRINGVIEW OCTAVE_CHECK_FUNC_QTEXTSTREAM_SETENCODING + OCTAVE_CHECK_ENUM_QT_KEY_MICRO OCTAVE_CHECK_QREGION_ITERATORS OCTAVE_CHECK_QT_IMCURSORRECTANGLE_ENUM_VALUE From fc683aa6e5ab7b5fee289dc2113eaf9fcaf202bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=BCtzel?= Date: Thu, 9 Jan 2025 12:08:18 +0100 Subject: [PATCH 3/6] GUI: Avoid deprecation warnings with Qt 6.7 or newer. * m4/acinclude.m4 (OCTAVE_CHECK_SIGNAL_QCHECKBOX_CHECKSTATECHANGED): Add check for signal "QCheckBox::checkStateChanged". (OCTAVE_CHECK_QT_VERSION): Use new check. * libgui/src/m-editor/find-dialog.cc (find_dialog::find_dialog), libgui/src/settings-dialog.cc (settings_dialog::read_settings, settings_dialog::read_workspace_colors, settings_dialog::read_terminal_colors, settings_dialog::read_varedit_colors), libgui/src/shortcuts-tree-widget.cc (shortcut_edit_dialog::shortcut_edit_dialog), libgui/src/welcome-wizard.cc (setup_community_news::setup_community_news): Use signal "QCheckBox::checkStateChanged" instead of "QCheckBox::stateChanged" if possible. --- libgui/src/m-editor/find-dialog.cc | 14 ++++++++++-- libgui/src/settings-dialog.cc | 28 ++++++++++++++++++++---- libgui/src/shortcuts-tree-widget.cc | 14 ++++++++++-- libgui/src/welcome-wizard.cc | 7 +++++- m4/acinclude.m4 | 33 +++++++++++++++++++++++++++++ 5 files changed, 87 insertions(+), 9 deletions(-) diff --git a/libgui/src/m-editor/find-dialog.cc b/libgui/src/m-editor/find-dialog.cc index d6f2f0e5af..502482252c 100644 --- a/libgui/src/m-editor/find-dialog.cc +++ b/libgui/src/m-editor/find-dialog.cc @@ -150,12 +150,22 @@ find_dialog::find_dialog (octave_dock_widget *ed, QWidget *p) this, &find_dialog::replace); connect (m_replace_all_button, &QPushButton::clicked, this, &find_dialog::replace_all); - connect (m_backward_check_box, &QCheckBox::stateChanged, + connect (m_backward_check_box, +#if defined (HAVE_QCHECKBOX_CHECKSTATECHANGED) + &QCheckBox::checkStateChanged, +#else + &QCheckBox::stateChanged, +#endif this, &find_dialog::handle_backward_search_changed); connect (m_button_box, &QDialogButtonBox::rejected, this, &find_dialog::close); - connect (m_search_selection_check_box, &QCheckBox::stateChanged, + connect (m_search_selection_check_box, +#if defined (HAVE_QCHECKBOX_CHECKSTATECHANGED) + &QCheckBox::checkStateChanged, +#else + &QCheckBox::stateChanged, +#endif this, &find_dialog::handle_sel_search_changed); QVBoxLayout *extension_layout = new QVBoxLayout (); diff --git a/libgui/src/settings-dialog.cc b/libgui/src/settings-dialog.cc index 47eab3a759..a839127be1 100644 --- a/libgui/src/settings-dialog.cc +++ b/libgui/src/settings-dialog.cc @@ -578,7 +578,12 @@ settings_dialog::read_settings (bool first) editor_styles_layout->addLayout (current_line); // update colors depending on second theme selection - connect (cb_color_mode, &QCheckBox::stateChanged, + connect (cb_color_mode, +#if defined (HAVE_QCHECKBOX_CHECKSTATECHANGED) + &QCheckBox::checkStateChanged, +#else + &QCheckBox::stateChanged, +#endif this, &settings_dialog::update_editor_lexers); connect (pb_reload_default_colors, &QPushButton::clicked, [this] () { update_editor_lexers (settings_reload_default_colors_flag); }); @@ -1507,7 +1512,12 @@ settings_dialog::read_workspace_colors () // update colors depending on second theme selection or reloading // the dfault values - connect (cb_color_mode, &QCheckBox::stateChanged, + connect (cb_color_mode, +#if defined (HAVE_QCHECKBOX_CHECKSTATECHANGED) + &QCheckBox::checkStateChanged, +#else + &QCheckBox::stateChanged, +#endif this, &settings_dialog::update_workspace_colors); connect (pb_reload_default_colors, &QPushButton::clicked, [this] () { update_workspace_colors (settings_reload_default_colors_flag); }); @@ -1622,7 +1632,12 @@ settings_dialog::read_terminal_colors () terminal_colors_box->setLayout (style_grid); // update colors depending on second theme selection - connect (cb_color_mode, &QCheckBox::stateChanged, + connect (cb_color_mode, +#if defined (HAVE_QCHECKBOX_CHECKSTATECHANGED) + &QCheckBox::checkStateChanged, +#else + &QCheckBox::stateChanged, +#endif this, &settings_dialog::update_terminal_colors); connect (pb_reload_default_colors, &QPushButton::clicked, [this] () { update_terminal_colors (settings_reload_default_colors_flag); }); @@ -1735,7 +1750,12 @@ settings_dialog::read_varedit_colors () varedit_colors_box->setLayout (style_grid); // update colors depending on second theme selection - connect (cb_color_mode, &QCheckBox::stateChanged, + connect (cb_color_mode, +#if defined (HAVE_QCHECKBOX_CHECKSTATECHANGED) + &QCheckBox::checkStateChanged, +#else + &QCheckBox::stateChanged, +#endif this, &settings_dialog::update_varedit_colors); connect (pb_reload_default_colors, &QPushButton::clicked, [this] () { update_varedit_colors (settings_reload_default_colors_flag); }); diff --git a/libgui/src/shortcuts-tree-widget.cc b/libgui/src/shortcuts-tree-widget.cc index 19bc5fa0bb..0d5b0c0b6b 100644 --- a/libgui/src/shortcuts-tree-widget.cc +++ b/libgui/src/shortcuts-tree-widget.cc @@ -246,10 +246,20 @@ shortcut_edit_dialog::shortcut_edit_dialog setLayout (box); - connect (direct, &QCheckBox::stateChanged, + connect (direct, +#if defined (HAVE_QCHECKBOX_CHECKSTATECHANGED) + &QCheckBox::checkStateChanged, +#else + &QCheckBox::stateChanged, +#endif m_edit_actual, &enter_shortcut::handle_direct_shortcut); - connect (shift, &QCheckBox::stateChanged, + connect (shift, +#if defined (HAVE_QCHECKBOX_CHECKSTATECHANGED) + &QCheckBox::checkStateChanged, +#else + &QCheckBox::stateChanged, +#endif m_edit_actual, &enter_shortcut::handle_shift_modifier); connect (this, &QDialog::finished, diff --git a/libgui/src/welcome-wizard.cc b/libgui/src/welcome-wizard.cc index dc7526329b..afc2bec607 100644 --- a/libgui/src/welcome-wizard.cc +++ b/libgui/src/welcome-wizard.cc @@ -300,7 +300,12 @@ setup_community_news::setup_community_news (welcome_wizard *wizard) m_next->setDefault (true); m_next->setFocus (); - connect (m_checkbox, &QCheckBox::stateChanged, + connect (m_checkbox, +#if defined (HAVE_QCHECKBOX_CHECKSTATECHANGED) + &QCheckBox::checkStateChanged, +#else + &QCheckBox::stateChanged, +#endif wizard, &welcome_wizard::handle_web_connect_option); connect (m_previous, &QPushButton::clicked, wizard, &welcome_wizard::previous_page); diff --git a/m4/acinclude.m4 b/m4/acinclude.m4 index 4a057a290b..71b5f3609f 100644 --- a/m4/acinclude.m4 +++ b/m4/acinclude.m4 @@ -797,6 +797,38 @@ AC_DEFUN([OCTAVE_CHECK_ENUM_QT_KEY_MICRO], [ fi ]) dnl +dnl Check whether the Qt class QCheckBox has the checkStateChanged +dnl signal. This signal was introduced in Qt 6.7. +dnl +dnl FIXME: Delete this entirely when we drop support for Qt 6.6 or older. +dnl +AC_DEFUN([OCTAVE_CHECK_SIGNAL_QCHECKBOX_CHECKSTATECHANGED], [ + AC_CACHE_CHECK([for QCheckBox::checkStateChanged signal], + [octave_cv_signal_qcheckbox_checkstatechanged], + [AC_LANG_PUSH(C++) + ac_octave_save_CPPFLAGS="$CPPFLAGS" + ac_octave_save_CXXFLAGS="$CXXFLAGS" + CPPFLAGS="$QT_CPPFLAGS $CXXPICFLAG $CPPFLAGS" + CXXFLAGS="$CXXPICFLAG $CXXFLAGS" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #include + ]], [[ + QCheckBox checkbox; + QObject::connect (&checkbox, &QCheckBox::checkStateChanged, + [] (Qt::CheckState) {}); + ]])], + octave_cv_signal_qcheckbox_checkstatechanged=yes, + octave_cv_signal_qcheckbox_checkstatechanged=no) + CPPFLAGS="$ac_octave_save_CPPFLAGS" + CXXFLAGS="$ac_octave_save_CXXFLAGS" + AC_LANG_POP(C++) + ]) + if test $octave_cv_signal_qcheckbox_checkstatechanged = yes; then + AC_DEFINE(HAVE_QCHECKBOX_CHECKSTATECHANGED, 1, + [Define to 1 if you have the `QCheckBox::checkStateChanged' signal.]) + fi +]) +dnl dnl Check whether HDF5 library has version 1.6 API functions. dnl AC_DEFUN([OCTAVE_CHECK_HDF5_HAS_VER_16_API], [ @@ -2296,6 +2328,7 @@ AC_DEFUN([OCTAVE_CHECK_QT_VERSION], [AC_MSG_CHECKING([Qt version $1]) OCTAVE_CHECK_CLASS_QSTRINGVIEW OCTAVE_CHECK_FUNC_QTEXTSTREAM_SETENCODING OCTAVE_CHECK_ENUM_QT_KEY_MICRO + OCTAVE_CHECK_SIGNAL_QCHECKBOX_CHECKSTATECHANGED OCTAVE_CHECK_QREGION_ITERATORS OCTAVE_CHECK_QT_IMCURSORRECTANGLE_ENUM_VALUE From 70898ae6478135c44e8a11357bb597eaa3e62dbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=BCtzel?= Date: Thu, 9 Jan 2025 12:30:43 +0100 Subject: [PATCH 4/6] GUI: Avoid deprecation warning with Qt 6.4 or newer. * m4/acinclude.m4 (OCTAVE_CHECK_ENUM_QT_KEY_MICRO): Add check for function "QColor::fromString". (OCTAVE_CHECK_QT_VERSION): Use new check. * libgui/graphics/annotation-dialog.cc (annotation_dialog::set_gui_props): Use "QColor::fromString" instead of "QColor::setNamedColor" if possible. --- libgui/graphics/annotation-dialog.cc | 4 ++++ m4/acinclude.m4 | 32 ++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/libgui/graphics/annotation-dialog.cc b/libgui/graphics/annotation-dialog.cc index 710b0073ee..aaa0c582fb 100644 --- a/libgui/graphics/annotation-dialog.cc +++ b/libgui/graphics/annotation-dialog.cc @@ -243,7 +243,11 @@ annotation_dialog::set_gui_props () if (m_props(1*i +1).is_matrix_type ()) color = octave::Utils::fromRgb (m_props(2*i +1).matrix_value ()); else +#if defined (HAVE_QCOLOR_FROMSTRING) + color.fromString (m_props(2*i +1).string_value ()); +#else color.setNamedColor (m_props(2*i +1).string_value ().c_str ()); +#endif if (color.isValid ()) m_ui->btn_color->setPalette (QPalette (color)); diff --git a/m4/acinclude.m4 b/m4/acinclude.m4 index 71b5f3609f..382513c2bc 100644 --- a/m4/acinclude.m4 +++ b/m4/acinclude.m4 @@ -829,6 +829,37 @@ AC_DEFUN([OCTAVE_CHECK_SIGNAL_QCHECKBOX_CHECKSTATECHANGED], [ fi ]) dnl +dnl Check whether the Qt class QColor has the fromString member function. +dnl This member function was introduced in Qt 6.4. +dnl +dnl FIXME: Delete this entirely when we drop support for Qt 6.3 or older. +dnl +AC_DEFUN([OCTAVE_CHECK_FUNC_QCOLOR_FROMSTRING], [ + AC_CACHE_CHECK([for QColor::fromString], + [octave_cv_func_qcolor_fromstring], + [AC_LANG_PUSH(C++) + ac_octave_save_CPPFLAGS="$CPPFLAGS" + ac_octave_save_CXXFLAGS="$CXXFLAGS" + CPPFLAGS="$QT_CPPFLAGS $CXXPICFLAG $CPPFLAGS" + CXXFLAGS="$CXXPICFLAG $CXXFLAGS" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #include + ]], [[ + QColor color; + color.fromString ("green"); + ]])], + octave_cv_func_qcolor_fromstring=yes, + octave_cv_func_qcolor_fromstring=no) + CPPFLAGS="$ac_octave_save_CPPFLAGS" + CXXFLAGS="$ac_octave_save_CXXFLAGS" + AC_LANG_POP(C++) + ]) + if test $octave_cv_func_qcolor_fromstring = yes; then + AC_DEFINE(HAVE_QCOLOR_FROMSTRING, 1, + [Define to 1 if you have the `QColor::fromString' member function.]) + fi +]) +dnl dnl Check whether HDF5 library has version 1.6 API functions. dnl AC_DEFUN([OCTAVE_CHECK_HDF5_HAS_VER_16_API], [ @@ -2329,6 +2360,7 @@ AC_DEFUN([OCTAVE_CHECK_QT_VERSION], [AC_MSG_CHECKING([Qt version $1]) OCTAVE_CHECK_FUNC_QTEXTSTREAM_SETENCODING OCTAVE_CHECK_ENUM_QT_KEY_MICRO OCTAVE_CHECK_SIGNAL_QCHECKBOX_CHECKSTATECHANGED + OCTAVE_CHECK_FUNC_QCOLOR_FROMSTRING OCTAVE_CHECK_QREGION_ITERATORS OCTAVE_CHECK_QT_IMCURSORRECTANGLE_ENUM_VALUE From 5e06d58b61c2fa0a98558a38de4dd08a9eb0153f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=BCtzel?= Date: Thu, 9 Jan 2025 12:38:58 +0100 Subject: [PATCH 5/6] build: Update list with linker flags recommended by gnulib bootstrap script. * configure.ac: Update values of GNULIB_LINK_DEPS and MKOCTFILE_GNULIB_LINK_DEPS with the current recommendations from the gnulib bootstrap script. --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 1feb3d4b35..259df2d084 100644 --- a/configure.ac +++ b/configure.ac @@ -2996,7 +2996,7 @@ fi ### Recommendations from the gnulib bootstrap script. -GNULIB_LINK_DEPS="$FREXPF_LIBM $FREXP_LIBM $GETHOSTNAME_LIB $LIBSOCKET $LIB_CLOCK_GETTIME $LIB_CRYPTO $LIB_GETLOGIN $LIB_NANOSLEEP $LIB_SELECT $LTLIBICONV $LTLIBINTL $LTLIBTHREAD $INTL_MACOSX_LIBS" +GNULIB_LINK_DEPS="$CLOCK_TIME_LIB $FREXPF_LIBM $FREXP_LIBM $GETHOSTNAME_LIB $GETHRXTIME_LIB $GETLOGIN_LIB $GETRANDOM_LIB $HARD_LOCALE_LIB $LIBPMULTITHREAD $LIBPTHREAD $LIBSOCKET $LIBTHREAD $LIB_CRYPTO $LTLIBC32CONV $LTLIBICONV $LTLIBINTL $LTLIBREADLINE $LTLIBUNISTRING $MBRTOWC_LIB $NANOSLEEP_LIB $PTHREAD_SIGMASK_LIB $SELECT_LIB $SETLOCALE_LIB $SETLOCALE_NULL_LIB $INTL_MACOSX_LIBS" ## FIXME: This is a kluge to transform $libdir/libiconv.dll.a to -liconv. ## It would probably be better to fix gnulib to not give us an absolute @@ -3014,7 +3014,7 @@ case $host_os in ;; esac -MKOCTFILE_GNULIB_LINK_DEPS="$FREXPF_LIBM $FREXP_LIBM $GETHOSTNAME_LIB $LIBSOCKET $LIB_CLOCK_GETTIME $LIB_CRYPTO $LIB_GETLOGIN $LIB_NANOSLEEP $LIB_SELECT $MKOCTFILE_LIBICONV $LIBINTL $LIBTHREAD $INTL_MACOSX_LIBS" +MKOCTFILE_GNULIB_LINK_DEPS="$CLOCK_TIME_LIB $FREXPF_LIBM $FREXP_LIBM $GETHOSTNAME_LIB $GETHRXTIME_LIB $GETLOGIN_LIB $GETRANDOM_LIB $HARD_LOCALE_LIB $LIBPMULTITHREAD $LIBPTHREAD $LIBSOCKET $LIBTHREAD $LIB_CRYPTO $LIBC32CONV $MKOCTFILE_LIBICONV $LIBINTL $LIBREADLINE $LIBUNISTRING $MBRTOWC_LIB $NANOSLEEP_LIB $PTHREAD_SIGMASK_LIB $SELECT_LIB $SETLOCALE_LIB $SETLOCALE_NULL_LIB $INTL_MACOSX_LIBS" AC_SUBST(GNULIB_LINK_DEPS) From 1f1a3a97874d9a2787b23f8054af460adf6c52f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=BCtzel?= Date: Thu, 9 Jan 2025 13:03:51 +0100 Subject: [PATCH 6/6] build: Update C++ standard detection with latest version from upstream. * m4/ax_cxx_compile_stdcxx.m4: Update with latest version from upstream. --- m4/ax_cxx_compile_stdcxx.m4 | 88 +++++++++++++++++++++++++++++-------- 1 file changed, 70 insertions(+), 18 deletions(-) diff --git a/m4/ax_cxx_compile_stdcxx.m4 b/m4/ax_cxx_compile_stdcxx.m4 index 8edf5152ec..fe6ae17e6c 100644 --- a/m4/ax_cxx_compile_stdcxx.m4 +++ b/m4/ax_cxx_compile_stdcxx.m4 @@ -10,8 +10,8 @@ # # Check for baseline language coverage in the compiler for the specified # version of the C++ standard. If necessary, add switches to CXX and -# CXXCPP to enable support. VERSION may be '11', '14', '17', or '20' for -# the respective C++ standard version. +# CXXCPP to enable support. VERSION may be '11', '14', '17', '20', or +# '23' for the respective C++ standard version. # # The second argument, if specified, indicates whether you insist on an # extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g. @@ -36,14 +36,15 @@ # Copyright (c) 2016, 2018 Krzesimir Nowak # Copyright (c) 2019 Enji Cooper # Copyright (c) 2020 Jason Merrill -# Copyright (c) 2021 Jörn Heusipp +# Copyright (c) 2021, 2024 Jörn Heusipp +# Copyright (c) 2015, 2022, 2023, 2024 Olly Betts # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. -#serial 18 +#serial 25 dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro dnl (serial version number 13). @@ -53,6 +54,7 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl [$1], [14], [ax_cxx_compile_alternatives="14 1y"], [$1], [17], [ax_cxx_compile_alternatives="17 1z"], [$1], [20], [ax_cxx_compile_alternatives="20"], + [$1], [23], [ax_cxx_compile_alternatives="23"], [m4_fatal([invalid first argument `$1' to AX_CXX_COMPILE_STDCXX])])dnl m4_if([$2], [], [], [$2], [ext], [], @@ -159,31 +161,41 @@ AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl dnl Test body for checking C++11 support m4_define([_AX_CXX_COMPILE_STDCXX_testbody_11], - _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 + [_AX_CXX_COMPILE_STDCXX_testbody_new_in_11] ) dnl Test body for checking C++14 support m4_define([_AX_CXX_COMPILE_STDCXX_testbody_14], - _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 - _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 + [_AX_CXX_COMPILE_STDCXX_testbody_new_in_11 + _AX_CXX_COMPILE_STDCXX_testbody_new_in_14] ) dnl Test body for checking C++17 support m4_define([_AX_CXX_COMPILE_STDCXX_testbody_17], - _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 - _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 - _AX_CXX_COMPILE_STDCXX_testbody_new_in_17 + [_AX_CXX_COMPILE_STDCXX_testbody_new_in_11 + _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 + _AX_CXX_COMPILE_STDCXX_testbody_new_in_17] ) dnl Test body for checking C++20 support m4_define([_AX_CXX_COMPILE_STDCXX_testbody_20], - _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 - _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 - _AX_CXX_COMPILE_STDCXX_testbody_new_in_17 - _AX_CXX_COMPILE_STDCXX_testbody_new_in_20 + [_AX_CXX_COMPILE_STDCXX_testbody_new_in_11 + _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 + _AX_CXX_COMPILE_STDCXX_testbody_new_in_17 + _AX_CXX_COMPILE_STDCXX_testbody_new_in_20] +) + +dnl Test body for checking C++23 support + +m4_define([_AX_CXX_COMPILE_STDCXX_testbody_23], + [_AX_CXX_COMPILE_STDCXX_testbody_new_in_11 + _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 + _AX_CXX_COMPILE_STDCXX_testbody_new_in_17 + _AX_CXX_COMPILE_STDCXX_testbody_new_in_20 + _AX_CXX_COMPILE_STDCXX_testbody_new_in_23] ) @@ -201,7 +213,17 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_11], [[ // MSVC always sets __cplusplus to 199711L in older versions; newer versions // only set it correctly if /Zc:__cplusplus is specified as well as a // /std:c++NN switch: +// // https://devblogs.microsoft.com/cppblog/msvc-now-correctly-reports-__cplusplus/ +// +// The value __cplusplus ought to have is available in _MSVC_LANG since +// Visual Studio 2015 Update 3: +// +// https://learn.microsoft.com/en-us/cpp/preprocessor/predefined-macros +// +// This was also the first MSVC version to support C++14 so we can't use the +// value of either __cplusplus or _MSVC_LANG to quickly rule out MSVC having +// C++11 or C++14 support, but we can check _MSVC_LANG for C++17 and later. #elif __cplusplus < 201103L && !defined _MSC_VER #error "This is not a C++11 compiler" @@ -617,7 +639,7 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_17], [[ #error "This is not a C++ compiler" -#elif __cplusplus < 201703L && !defined _MSC_VER +#elif (defined _MSVC_LANG ? _MSVC_LANG : __cplusplus) < 201703L #error "This is not a C++17 compiler" @@ -983,7 +1005,7 @@ namespace cxx17 } // namespace cxx17 -#endif // __cplusplus < 201703L && !defined _MSC_VER +#endif // (defined _MSVC_LANG ? _MSVC_LANG : __cplusplus) < 201703L ]]) @@ -996,7 +1018,7 @@ m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_20], [[ #error "This is not a C++ compiler" -#elif __cplusplus < 202002L && !defined _MSC_VER +#elif (defined _MSVC_LANG ? _MSVC_LANG : __cplusplus) < 202002L #error "This is not a C++20 compiler" @@ -1013,6 +1035,36 @@ namespace cxx20 } // namespace cxx20 -#endif // __cplusplus < 202002L && !defined _MSC_VER +#endif // (defined _MSVC_LANG ? _MSVC_LANG : __cplusplus) < 202002L + +]]) + + +dnl Tests for new features in C++23 + +m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_23], [[ + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif (defined _MSVC_LANG ? _MSVC_LANG : __cplusplus) < 202302L + +#error "This is not a C++23 compiler" + +#else + +#include + +namespace cxx23 +{ + +// As C++23 supports feature test macros in the standard, there is no +// immediate need to actually test for feature availability on the +// Autoconf side. + +} // namespace cxx23 + +#endif // (defined _MSVC_LANG ? _MSVC_LANG : __cplusplus) < 202302L ]])