Skip to content

Commit 4979a5c

Browse files
authored
Fix compilation with Cython3.1. (#1184)
Thanks to ahesford: Failure to compile with Cython 3.1 is caused by a collision between struct hackrf_device_list and the function hackrf_device_list. In the C library that this wraps, the two names are distinct. Cython, however, folds struct hackrf_device_list into just hackrf_device_list. Fortunately, Cython allows the use of a name for its definitions that differs from the underlying C name, so the struct can just be called c_hackrf_device_list. This doesn't seem to be a critical change because the immediately following typedef just aliases this to hackrf_device_list_t everywhere it is needed. Cf. http://docs.cython.org/en/stable/src/userguide/external_C_code.html#resolving-naming-conflicts-c-name-specifications
1 parent 9061187 commit 4979a5c

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

data/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
numpy<3.0
22
pyqt5
33
psutil
4-
cython<3.1
4+
cython
55
setuptools

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def read_long_description():
142142
return ""
143143

144144

145-
install_requires = ["numpy<3.0", "psutil", "cython<3.1", "setuptools"]
145+
install_requires = ["numpy<3.0", "psutil", "cython", "setuptools"]
146146
if IS_RELEASE:
147147
install_requires.append("pyqt5")
148148
else:

src/urh/dev/native/lib/chackrf.pxd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ cdef extern from "libhackrf/hackrf.h":
5454
uint32_t part_id[2]
5555
uint32_t serial_no[4]
5656

57-
ctypedef struct hackrf_device_list:
57+
ctypedef struct c_hackrf_device_list "hackrf_device_list":
5858
char ** serial_numbers
5959
hackrf_usb_board_id * usb_board_ids
6060
int *usb_device_index
@@ -63,7 +63,7 @@ cdef extern from "libhackrf/hackrf.h":
6363
void ** usb_devices
6464
int usb_devicecount
6565

66-
ctypedef hackrf_device_list hackrf_device_list_t;
66+
ctypedef c_hackrf_device_list hackrf_device_list_t;
6767

6868
ctypedef int (*hackrf_sample_block_cb_fn)(hackrf_transfer* transfer)
6969

0 commit comments

Comments
 (0)