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

Hamlib broke compilation of 'rig/RigThread.cpp' #1020

Open
gvanem opened this issue Dec 12, 2023 · 0 comments
Open

Hamlib broke compilation of 'rig/RigThread.cpp' #1020

gvanem opened this issue Dec 12, 2023 · 0 comments

Comments

@gvanem
Copy link

gvanem commented Dec 12, 2023

A recent commit in Hamlib, broke the compilation of rig/RigThread.cpp:

rig/RigThread.cpp(28): error C2664: 'int rig_list_foreach(int (__cdecl *)(rig_caps *,void *),void *)': 
cannot convert argument 1 from 'int (__cdecl *)(const rig_caps *,void *)' to 'int (__cdecl *)(rig_caps *,void *)'
rig/RigThread.cpp(28): note: None of the functions with this name in scope match the target type

But now Hamlib has also a #define RIGCAPS_NOT_CONST to test for.

This is how I hacked around this issue:

--- a/rig/RigThread.cpp 2023-06-01 06:15:02
+++ b/rig/RigThread.cpp 2023-12-12 17:45:41
@@ -32,7 +32,7 @@
     return RigThread::rigCaps;
 }

-int RigThread::add_hamlib_rig(const struct rig_caps *rc, void* /* f */)
+int RigThread::add_hamlib_rig(HAMLIB_RIG_CAPS *rc, void* /* f */)
 {
     rigCaps.push_back(rc);
     return 1;

--- a/rig/RigThread.h 2023-06-01 06:15:02
+++ b/rig/RigThread.h 2023-12-12 17:45:34
@@ -12,6 +12,18 @@
        #define FILPATHLEN HAMLIB_FILPATHLEN
 #endif

+#ifdef RIGCAPS_NOT_CONST
+
+  /* Since this commit:
+   *   https://github.com/Hamlib/Hamlib/commit/ed941939359da9f8734dbdf4a21a9b01622a1a6e
+   * a 'struct rig_caps' is no longer constant (as passed to 'rig_list_foreach()' etc.).
+   */
+
+  #define HAMLIB_RIG_CAPS struct rig_caps
+#else
+  #define HAMLIB_RIG_CAPS const struct rig_caps
+#endif
+
 struct rigGreater
 {
     bool operator()( const struct rig_caps *lx, const struct rig_caps *rx ) const {
@@ -50,7 +62,7 @@
     std::string getErrorMessage();

     static RigList &enumerate();
-    static int add_hamlib_rig(const struct rig_caps *rc, void* f);
+    static int add_hamlib_rig(HAMLIB_RIG_CAPS *rc, void* f);

 protected:
     void setErrorStateFromHamlibCode(int errcode);

I'm on Win-10 using MSVC (x64).

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