I've applied this patch adding a C++ test for the byteswap.h
substitute. I guess there wasn't a need before since it only defined
macros, but now it defines functions.

Collin
From 8658d279727e9e54d01d7ae38a9c5170893d3507 Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Sat, 25 May 2024 01:20:01 -0700
Subject: [PATCH] byteswap tests: Verify header can be used from C++.

* modules/byteswap-c++-tests: New file.
* tests/test-byteswap-c++.cc: New file.
* modules/byteswap-tests (Depends-on): Add byteswap-c++-tests.
---
 ChangeLog                  |  7 +++++++
 modules/byteswap-c++-tests | 17 +++++++++++++++++
 modules/byteswap-tests     |  1 +
 tests/test-byteswap-c++.cc | 27 +++++++++++++++++++++++++++
 4 files changed, 52 insertions(+)
 create mode 100644 modules/byteswap-c++-tests
 create mode 100644 tests/test-byteswap-c++.cc

diff --git a/ChangeLog b/ChangeLog
index 0a6def457d..52d51ba5a7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2024-05-25  Collin Funk  <collin.fu...@gmail.com>
+
+	byteswap tests: Verify header can be used from C++.
+	* modules/byteswap-c++-tests: New file.
+	* tests/test-byteswap-c++.cc: New file.
+	* modules/byteswap-tests (Depends-on): Add byteswap-c++-tests.
+
 2024-05-24  Collin Funk  <collin.fu...@gmail.com>
 
 	readutmp: Fix dependencies.
diff --git a/modules/byteswap-c++-tests b/modules/byteswap-c++-tests
new file mode 100644
index 0000000000..05cdc94875
--- /dev/null
+++ b/modules/byteswap-c++-tests
@@ -0,0 +1,17 @@
+Files:
+tests/test-byteswap-c++.cc
+
+Status:
+c++-test
+
+Depends-on:
+ansi-c++-opt
+
+configure.ac:
+
+Makefile.am:
+if ANSICXX
+TESTS += test-byteswap-c++
+check_PROGRAMS += test-byteswap-c++
+test_byteswap_c___SOURCES = test-byteswap-c++.cc
+endif
diff --git a/modules/byteswap-tests b/modules/byteswap-tests
index 64baf0e404..e148c5f7f3 100644
--- a/modules/byteswap-tests
+++ b/modules/byteswap-tests
@@ -4,6 +4,7 @@ tests/macros.h
 
 Depends-on:
 stdint
+byteswap-c++-tests
 
 configure.ac:
 
diff --git a/tests/test-byteswap-c++.cc b/tests/test-byteswap-c++.cc
new file mode 100644
index 0000000000..8276840233
--- /dev/null
+++ b/tests/test-byteswap-c++.cc
@@ -0,0 +1,27 @@
+/* Test the <byteswap.h> substitute in C++ mode.
+   Copyright (C) 2024 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
+
+/* Written by Collin Funk <collin.fu...@gmail.com>, 2024.  */
+
+#define GNULIB_NAMESPACE gnulib
+#include <config.h>
+
+#include <byteswap.h>
+
+int
+main ()
+{
+}
-- 
2.45.1

Reply via email to