Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
n1ai opened this issue Mar 2, 2024 · 0 comments
Open

Comments

@n1ai
Copy link

n1ai commented Mar 2, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant