From 269506ef977c384b179c25b69caa928b5393981e Mon Sep 17 00:00:00 2001 From: Ihor Dutchak Date: Thu, 21 May 2026 00:19:12 +0300 Subject: [PATCH] ci: build libusb and hidraw backends as C++ on ubuntu MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue #671 reported that libusb/hid.c failed to compile as C++ source; PR #811 made it C++-clean. linux/hid.c already builds as C++. There is no CI step that exercises the C++ compilation path, so a similar regression could slip through unnoticed. Add a step to the ubuntu-cmake job that compiles libusb/hid.c and linux/hid.c with `g++ -xc++ -Wall -Wextra -Werror -Wformat-signedness`. That matches the existing C build's warning set, except `-pedantic` is omitted: libusb.h declares zero-size arrays and hidapi relies on designated initialisers — both GNU extensions that g++ accepts in its default mode but rejects under strict ISO C++. Assisted-by: Claude:claude-opus-4.7 --- .github/workflows/builds.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/workflows/builds.yml b/.github/workflows/builds.yml index 83ebe190a..84a096fc7 100644 --- a/.github/workflows/builds.yml +++ b/.github/workflows/builds.yml @@ -154,6 +154,21 @@ jobs: cd build/static_test make install + - name: Check C++ compile (backends as C++ sources) + working-directory: hidapisrc + # Verify the libusb/hidraw backend sources still compile as C++, + # so regressions of #671 are caught. -pedantic is intentionally not + # used here: libusb.h declares zero-size arrays and we rely on + # designated initialisers, both GNU extensions that g++ accepts in + # its default mode but rejects under strict ISO C++. + run: | + g++ -xc++ -Wall -Wextra -Werror -Wformat-signedness -D_GNU_SOURCE \ + -I hidapi -I libusb $(pkg-config --cflags libusb-1.0) \ + -c libusb/hid.c -o /tmp/hid_libusb_cxx.o + g++ -xc++ -Wall -Wextra -Werror -Wformat-signedness -D_GNU_SOURCE \ + -I hidapi -I linux $(pkg-config --cflags libudev) \ + -c linux/hid.c -o /tmp/hid_hidraw_cxx.o + - name: Check Meson build run: | meson setup build_meson hidapisrc