ci: build libusb and hidraw backends as C++ on ubuntu#812
Open
Youw wants to merge 1 commit into
Open
Conversation
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
mcuee
approved these changes
May 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Issue #671 reported that
libusb/hid.cfailed to compile as C++ source. PR #811 made it C++-clean;linux/hid.calready builds as C++. Today nothing in CI exercises the C++ compilation path, so a similar regression could slip through unnoticed.Change
Add a single step to the
ubuntu-cmakejob that compiles both backendhid.cfiles withg++ -xc++:Flag set mirrors
GNU_COMPILE_FLAGSused by the existing C build, except-pedanticis omitted. Rationale:libusb.hdeclares zero-size arrays (#define ZERO_SIZED_ARRAY 0) and hidapi relies on designated initialisers — both GNU extensions that g++ accepts in its default mode but rejects under strict ISO C++. The check is meant to catch real cross-language regressions (#671-style implicit conversions), not those existing-by-design extensions.No source changes; this only adds the CI guard.
Verification
Ran the exact two commands locally against current master in WSL Ubuntu (gcc/g++ 11.4, libusb-1.0):
Also confirmed that reverting commit
e8243e1(the #671 fix) makes the libusb command fail with the sameinvalid conversionerrors the original issue reported — so this CI step will actually catch a regression of that fix.Drafted with Claude Code.