Skip to content

Commit c181b79

Browse files
committed
Fix type error in initGEOS() call
The function pointers passed to initGEOS() did not have the correct type. A proper fix needs <stdarg.h> support in Cython, which is currently missing. This fixes a build failure with Clang 16 and GCC 14. src/_geoslib.c: In function ‘__pyx_pymod_exec__geoslib’: src/_geoslib.c:8803:12: error: passing argument 1 of ‘initGEOS’ from incompatible pointer type 8803 | initGEOS(__pyx_f_8_geoslib_notice_h, __pyx_f_8_geoslib_error_h); | ^~~~~~~~~~~~~~~~~~~~~~~~~~ | | | void (*)(char *, char *) In file included from src/_geoslib.c:1219: /usr/include/geos_c.h:2074:24: note: expected ‘GEOSMessageHandler’ {aka ‘void (*)(const char *, ...)’} but argument is of type ‘void (*)(char *, char *)’ 2074 | GEOSMessageHandler notice_function, | ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~ src/_geoslib.c:8803:40: error: passing argument 2 of ‘initGEOS’ from incompatible pointer type 8803 | initGEOS(__pyx_f_8_geoslib_notice_h, __pyx_f_8_geoslib_error_h); | ^~~~~~~~~~~~~~~~~~~~~~~~~ | | | void (*)(char *, char *) /usr/include/geos_c.h:2075:24: note: expected ‘GEOSMessageHandler’ {aka ‘void (*)(const char *, ...)’} but argument is of type ‘void (*)(char *, char *)’ 2075 | GEOSMessageHandler error_function); | ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
1 parent 0d90252 commit c181b79

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

packages/basemap/src/_geoslib.pyx

+6-4
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ cdef extern from "geos_c.h":
5454
# Cython 3: Next ctypedef needs "noexcept" declaration unless
5555
# the compiler directive "legacy_implicit_noexcept" is used
5656
# ("noexcept" syntax supported since Cython 0.29.31).
57-
ctypedef void (*GEOSMessageHandler)(char *fmt, char *list)
57+
ctypedef void (*GEOSMessageHandler)(const char *fmt, ...)
5858
char *GEOSversion()
5959
void initGEOS(GEOSMessageHandler notice_function, GEOSMessageHandler error_function)
6060
void finishGEOS()
@@ -111,7 +111,7 @@ cdef extern from "geos_c.h":
111111
# Cython 3: Next cdef needs "noexcept" declaration unless
112112
# the compiler directive "legacy_implicit_noexcept" is used
113113
# ("noexcept" syntax supported since Cython 0.29.31).
114-
cdef void notice_h(char *fmt, char*msg):
114+
cdef void notice_h(const char *fmt, ...):
115115
pass
116116
#format = PyBytes_FromString(fmt)
117117
#message = PyBytes_FromString(msg)
@@ -124,7 +124,9 @@ cdef void notice_h(char *fmt, char*msg):
124124
# Cython 3: Next cdef needs "noexcept" declaration unless
125125
# the compiler directive "legacy_implicit_noexcept" is used
126126
# ("noexcept" syntax supported since Cython 0.29.31).
127-
cdef void error_h(char *fmt, char*msg):
127+
# FIXME: The type should be: error_h(const char *fmt, ...), but
128+
# Cython does not currently support varargs functions.
129+
cdef void error_h(const char *fmt, char*msg):
128130
format = PyBytes_FromString(fmt)
129131
message = PyBytes_FromString(msg)
130132
try:
@@ -142,7 +144,7 @@ __geos_major_version__ = GEOS_VERSION_MAJOR
142144
# raise ValueError('version 2.2.3 of the geos library is required')
143145

144146
# intialize GEOS (parameters are notice and error function callbacks).
145-
initGEOS(notice_h, error_h)
147+
initGEOS(notice_h, <GEOSMessageHandler>error_h)
146148

147149
cdef class BaseGeometry:
148150
cdef GEOSGeometry *_geom

0 commit comments

Comments
 (0)