Skip to content

SoapyAudio with USE_HAMLIB=1 fails to compile with Hamlib version >= 4.6 #22

@n1ai

Description

@n1ai

I am compiling SoapyAudio with the current top-of-tree Hamlib which is 4.6-git.

In git blame for include/hamlib/rig.h we see that the first arg to rig_list_foreach() has gone from 'const int' to just 'int'.

This results in the error:

SoapyAudio/Registration.cpp:92:25: error: invalid conversion from ‘int (*)(const rig_caps*, void*)’ to ‘int (*)(rig_caps*, void*)’ [-fpermissive]
   92 |         rig_list_foreach(SoapyAudio::add_hamlib_rig, 0);
      |         ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                         |
      |                         int (*)(const rig_caps*, void*)

The fix is easy, just get rid of 'const' in two places:

$ git diff | cat
diff --git a/Registration.cpp b/Registration.cpp
index 82a3452..dae1891 100644
--- a/Registration.cpp
+++ b/Registration.cpp
@@ -97,7 +97,7 @@ static std::vector<SoapySDR::Kwargs> findAudio(const SoapySDR::Kwargs &args)
 }
 
 #ifdef USE_HAMLIB
-int SoapyAudio::add_hamlib_rig(const struct rig_caps *rc, void* f)
+int SoapyAudio::add_hamlib_rig(struct rig_caps *rc, void* f)
 {
     rigCaps.push_back(rc);
 	return 1;
diff --git a/SoapyAudio.hpp b/SoapyAudio.hpp
index 6eefb76..1a68589 100644
--- a/SoapyAudio.hpp
+++ b/SoapyAudio.hpp
@@ -259,7 +259,7 @@ public:
 
 #ifdef USE_HAMLIB
 public:
-    static int add_hamlib_rig(const struct rig_caps *rc, void* f);
+    static int add_hamlib_rig(struct rig_caps *rc, void* f);
     static std::vector<const struct rig_caps *> rigCaps;
     
     void checkRigThread();

I will leave it up to the SoapyAudio maintainers as to when and how to fix this.

The compiler is hinting that '-fpermissive' would make this error go away.

Maybe that's the best way to handle it, either on the command line or in a directive in the source code, given that it's best to tolerate both old and new versions of hamlib.

Regards,
Dave, N1AI

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions