Build cleanly against UHD 4.10#70
Open
gretel wants to merge 2 commits into
Open
Conversation
UHD 4.10's <uhd/utils/cast.hpp> (transitively included via <uhd/usrp/multi_usrp.hpp>) uses C++17 type traits (std::is_floating_point_v, std::is_enum_v, std::is_same_v, std::enable_if_t with auto return type deduction). Building SoapyUHD as C++14 against UHD 4.10 fails with 'no member named to_str in namespace uhd::cast' because the SFINAE overloads can't be parsed. C++17 is the minimum required to consume UHD >= 4.10 headers. UHD 4.10 itself bumped to C++20 internally; consumers can stay on C++17. Signed-off-by: Tom Hensel <code@jitter.eu>
Two compiler-warning cleanups exposed by building against UHD 4.10 under -Wswitch / -Winconsistent-missing-override: 1. uhd::async_metadata_t::EVENT_CODE_OK was added in UHD 4.10 (commit that introduces the OK / non-error completion event). The readStreamStatus() switch in SoapyUHDDevice silently fell through for it and returned 0 -- functionally OK, but produced a 'enumeration value EVENT_CODE_OK not handled in switch' warning. Add an explicit case under '#if UHD_VERSION >= 4100000' that does the same thing (no flags set, no error). The version guard preserves compatibility with UHD 4.0..4.9 which don't have the enumerator yet. 2. UHDSoapyRxStream and UHDSoapyTxStream override eight virtuals from uhd::rx_streamer / uhd::tx_streamer (get_num_channels, get_max_num_samps, recv, issue_stream_cmd, send, recv_async_msg). Mark them with the 'override' keyword. This is harmless under pre-C++11 -- but at C++17/20 it gives the compiler the signal to diagnose accidental signature drift if UHD changes any base class prototype in a future minor release. Together these resolve the two remaining 'warning:' lines in the build output. Verified clean against uhd-oc 4.10.0.0 keg. Signed-off-by: Tom Hensel <code@jitter.eu>
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.
Build cleanly against UHD 4.10
Changed
CMAKE_CXX_STANDARDfrom 14 to 17.EVENT_CODE_OKin the async-metadata switch.overridespecifier to virtual stream methods.Why
UHD 4.10 public headers (e.g.
uhd::cast::to_strinassert_has.ipp) require C++17 (std::optional,std::is_same_v).EVENT_CODE_OKis new in 4.10 and triggers-Wswitch.overridesilences-Winconsistent-missing-override.