debrouxl / tilibs

TILP (formerly GtkTiLink) can transfer data between Texas Instruments graphing calculators and a computer. It works with all link cables (parallel, serial, Black/Gray/Silver/Direct Link) and it supports the TI-Z80 series (73..86), the TI-eZ80 series (83PCE, 84+CE), the TI-68k series (89, 92, 92+, V200, 89T) and the Nspire series (Nspire Clickpad / Touchpad / CX, both CAS and non-CAS)
http://lpg.ticalc.org/prj_tilp
63 stars 23 forks source link

libticalcs Fails to Build on Mac #80

Closed JLP04 closed 1 year ago

JLP04 commented 1 year ago

MacOS Ventura 13.5.1 (Intel) Latest commit of tilibs

When building libticalcs, make returns the following:

dusb_vpkt.cc:368:35: error: invalid use of non-static data member 'data'
        if (size > sizeof(DUSBRawPacket::data) + 1)
                          ~~~~~~~~~~~~~~~^~~~
dusb_vpkt.cc:371:32: error: invalid use of non-static data member 'data'
                size = sizeof(DUSBRawPacket::data) + 1;
                              ~~~~~~~~~~~~~~~^~~~
2 errors generated.
make[4]: *** [libticalcs2_la-dusb_vpkt.lo] Error 1
make[3]: *** [all-recursive] Error 1
make[2]: *** [all] Error 2
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
adriweb commented 1 year ago

That probably just means you have old tilibs headers installed on your system somewhere and it's using that instead. Make sure to remove old versions, then building again should work fine.

debrouxl commented 1 year ago

That issue was recently reported on IRC, on Mac-class hardware and software as well. The result of the discussion was that while some creative C++ coding could fix this, the simpler and more portable solution is to add and use a #define for the length of a DUSBRawPacket's data. There's already a #define for the length of Nspire packets anyway.

JLP04 commented 1 year ago

I don't know enough C++ to fix the build.

debrouxl commented 1 year ago

Something like

diff --git a/libticalcs/trunk/src/dusb_vpkt.cc b/libticalcs/trunk/src/dusb_vpkt.cc
index e1e55c0a..67557cc7 100644
--- a/libticalcs/trunk/src/dusb_vpkt.cc
+++ b/libticalcs/trunk/src/dusb_vpkt.cc
@@ -365,10 +365,10 @@ TIEXPORT3 int TICALL dusb_set_buf_size(CalcHandle* handle, uint32_t size)
 {
        VALIDATE_HANDLE(handle);

-       if (size > sizeof(DUSBRawPacket::data) + 1)
+       if (size > DUSB_DATA_SIZE + 1)
        {
                ticalcs_warning("Clamping dubious large DUSB buffer size");
-               size = sizeof(DUSBRawPacket::data) + 1;
+               size = DUSB_DATA_SIZE + 1;
        }

        handle->priv.dusb_rpkt_maxlen = size;
diff --git a/libticalcs/trunk/src/ticalcs.h b/libticalcs/trunk/src/ticalcs.h
index 95db4493..e8c38028 100644
--- a/libticalcs/trunk/src/ticalcs.h
+++ b/libticalcs/trunk/src/ticalcs.h
@@ -352,6 +352,8 @@ typedef struct

 //! Size of the header of a \a DUSBRawPacket
 #define DUSB_HEADER_SIZE (4+1)
+//! Size of the data contained in \a DUSBRawPacket
+#define DUSB_DATA_SIZE (1023)

 /**
  * DUSBRawPacket:
@@ -360,10 +362,10 @@ typedef struct
  **/
 typedef struct
 {
-       uint32_t size;       ///< raw packet size
-       uint8_t  type;       ///< raw packet type
+       uint32_t size;                 ///< raw packet size
+       uint8_t  type;                 ///< raw packet type

-       uint8_t  data[1023]; ///< raw packet data
+       uint8_t  data[DUSB_DATA_SIZE]; ///< raw packet data
 } DUSBRawPacket;

 /**

but I'm in the middle of other changes in that repository clone :)

JLP04 commented 1 year ago

Cool, thanks.

JLP04 commented 1 year ago

I confirm this works on macOS.

JLP04 commented 1 year ago

Fixed by bfd030c.