ofalk / libdnet

libdnet provides a simplified, portable interface to several low-level networking routines.
Other
153 stars 60 forks source link

dnet 1.16.1 with python 3.11 error: incomplete definition of type 'struct _frame' #74

Closed AngryPenguinPL closed 2 years ago

AngryPenguinPL commented 2 years ago

Hi. When I try compile libdnet 1.16.1 I see this error:

/dnet.c:25190:5: error: incomplete definition of type 'struct _frame'
DEBUG util.py:444:      __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
DEBUG util.py:444:      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DEBUG util.py:444:  ./dnet.c:456:62: note: expanded from macro '__Pyx_PyFrame_SetLineNumber'
DEBUG util.py:444:    #define __Pyx_PyFrame_SetLineNumber(frame, lineno)  (frame)->f_lineno = (lineno)
DEBUG util.py:444:                                                        ~~~~~~~^
DEBUG util.py:444:  /usr/include/python3.11/pytypedefs.h:22:16: note: forward declaration of 'struct _frame'
DEBUG util.py:444:  typedef struct _frame PyFrameObject;
DEBUG util.py:444:                 ^
DEBUG util.py:444:  26 warnings and 1 error generated.
DEBUG util.py:444:  error: command '/usr/bin/clang' failed with exit code 1
DEBUG util.py:444:  make[1]: *** [Makefile:855: python-build] Error 1
DEBUG util.py:444:  make: *** [Makefile:492: all-recursive] Error 1

Same error is on Clang 14.0.5 and GCC 12. Worth to add I use Python 3.11 and maybe this cause issue.

Full build log: https://file-store.openmandriva.org/api/v1/file_stores/4e3213be81af54d7d6e94fbedb4011a0d0782b29.log?show=true

ofalk commented 2 years ago

Hi!

Thanks for opening this issue @AngryPenguinPL !

Looking at the full build log, it looks like you're missing libbsd(-devel). Can you try compiling with the same installed?

AngryPenguinPL commented 2 years ago

Yes. With libbsd there is the same error https://file-store.openmandriva.org/api/v1/file_stores/2a4359b39d46db091a79a8cac5f45e1e75710108.log?show=true

ofalk commented 2 years ago

Sorry for the late reply, but since I didn't have any OpenMandriva install at hand, I first had to get one running.

Can you try applying the following patch?

index d9cbc90..8201104 100644
--- a/python/dnet.pyx
+++ b/python/dnet.pyx
@@ -43,6 +43,9 @@ cdef extern from *:
 cdef extern from "string.h":
     int     strlcpy(char *dst, char *src, int size)

+cdef extern from "bsd/string.h":
+    int     strlcpy(char *dst, char *src, int size)
+
 cdef __memcpy(char *dst, object src, int n):
     if PyBytes_Size(src) != n:
         raise ValueError, "not a %d-byte binary string: %r" % (n, src)
AngryPenguinPL commented 2 years ago

Yes, this patch works. Package now compiling fine. Thanks.

ofalk commented 2 years ago

Thanks for the confirmation. I've fixed it in devel now. I guess you can live with having the patch in the RPM spec for the moment?

AngryPenguinPL commented 2 years ago

Yes, that's not a problem for me.

ofalk commented 2 years ago

Perfect! Thank you!