Fix compiler error with Hamlib 5.0. (#1477)

* Fix compiler error with Hamlib 5.0.

* Fix typo.

* Bring back old code for Ubuntu 22.04.

* Update CMake to explicitly look for rig_state.h.

* Add PR #1477 to changelog.

* Fix typo.
tmiw-patch-2
Mooneer Salem 2026-09-02 21:46:35 -07:00 committed by GitHub
parent 1f0b6c19c5
commit fe0986d497
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 24 additions and 1 deletions

View File

@ -526,6 +526,17 @@ if(HAMLIB_LIBRARY AND HAMLIB_INCLUDE_DIR)
endif (NOT HAMLIB_VERSION STRLESS "Hamlib 4.5")
endif (NOT HAMLIB_COMPILE_RESULT OR NOT HAMLIB_RUN_RESULT OR NOT HAMLIB_VERSION)
endif (NOT CMAKE_CROSSCOMPILING)
# Hamlib 4.7+ moves rig_state to hamlib/rig_state.h. Look for this file.
find_file(
HAMLIB_RIG_STATE_H
"rig_state.h"
PATHS "${HAMLIB_INCLUDE_DIR}/hamlib"
NO_DEFAULT_PATH)
if (NOT HAMLIB_RIG_STATE_H STREQUAL "HAMLIB_RIG_STATE_H-NOTFOUND")
message(STATUS "Hamlib: rig state is in rig_state.h, not rig.h.")
add_definitions(-DHAMLIB_USE_SEPARATE_RIG_STATE_H)
endif (NOT HAMLIB_RIG_STATE_H STREQUAL "HAMLIB_RIG_STATE_H-NOTFOUND")
else(HAMLIB_LIBRARY AND HAMLIB_INCLUDE_DIR)
message(STATUS "Using own Hamlib build")
include(cmake/BuildHamlib.cmake)

View File

@ -952,6 +952,7 @@ LDPC | Low Density Parity Check Codes - a family of powerful FEC codes
1. Bugfixes:
* Add logic to prevent FIFO sizes that are too small to allow TX thread to function. (PR #1474)
* Fix RX/TX level-meter gauge contamination. (PR #1475) - thanks @barjac!
* Fix Hamlib-related build failure with Hamlib 5.0~git. (PR #1477)
* macOS: Fix dyld error on startup when enabling sanitizers in build. (PR #1478)
## V2.4.0 August 2026

View File

@ -49,3 +49,4 @@ set(HAMLIB_ADD_DEPENDENCY TRUE)
add_definitions(-DHAMLIB_USE_FRIENDLY_ERRORS)
add_definitions(-DHAMLIB_CONST_WORKAROUND)
add_definitions(-DHAMLIB_USE_SEPARATE_RIG_STATE_H)

View File

@ -34,6 +34,10 @@
#include "util/logging/ulog.h"
#if defined(HAMLIB_USE_SEPARATE_RIG_STATE_H)
#include <hamlib/rig_state.h>
#endif // defined(HAMLIB_USE_SEPARATE_RIG_STATE_H)
#if defined(HAMLIB_USE_FRIENDLY_ERRORS)
#define HAMLIB_FRIENDLY_ERROR_FN rigerror2
#else
@ -462,7 +466,13 @@ void HamlibRigController::connectImpl_()
// Determine whether we have multiple VFOs.
multipleVfos_ = false;
vfo_t vfo;
if (rig_get_vfo (tmpRig, &vfo) == RIG_OK && (tmpRig->state.vfo_list & RIG_VFO_B))
if (rig_get_vfo (tmpRig, &vfo) == RIG_OK &&
#if HAMLIB_CONST_WORKAROUND
/* 4.6+ */
(HAMLIB_STATE(tmpRig)->vfo_list & RIG_VFO_B))
#else
(tmpRig->state.vfo_list & RIG_VFO_B))
#endif // HAMLIB_CONST_WORKAROUND
{
multipleVfos_ = true;
}