Skip to content

Commit 237b50e

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 12eddf0 commit 237b50e

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
@@ -53,7 +53,7 @@ cdef extern from "geos_c.h":
5353
# Cython 3: Next ctypedef needs "noexcept" declaration unless
5454
# the compiler directive "legacy_implicit_noexcept" is used
5555
# ("noexcept" syntax supported since Cython 0.29.31).
56-
ctypedef void (*GEOSMessageHandler)(char *fmt, char *list)
56+
ctypedef void (*GEOSMessageHandler)(const char *fmt, ...)
5757
char *GEOSversion()
5858
void initGEOS(GEOSMessageHandler notice_function, GEOSMessageHandler error_function)
5959
void finishGEOS()
@@ -110,7 +110,7 @@ cdef extern from "geos_c.h":
110110
# Cython 3: Next cdef needs "noexcept" declaration unless
111111
# the compiler directive "legacy_implicit_noexcept" is used
112112
# ("noexcept" syntax supported since Cython 0.29.31).
113-
cdef void notice_h(char *fmt, char*msg):
113+
cdef void notice_h(const char *fmt, ...):
114114
pass
115115
#format = PyBytes_FromString(fmt)
116116
#message = PyBytes_FromString(msg)
@@ -123,7 +123,9 @@ cdef void notice_h(char *fmt, char*msg):
123123
# Cython 3: Next cdef needs "noexcept" declaration unless
124124
# the compiler directive "legacy_implicit_noexcept" is used
125125
# ("noexcept" syntax supported since Cython 0.29.31).
126-
cdef void error_h(char *fmt, char*msg):
126+
# FIXME: The type should be: error_h(const char *fmt, ...), but
127+
# Cython does not currently support varargs functions.
128+
cdef void error_h(const char *fmt, char*msg):
127129
format = PyBytes_FromString(fmt)
128130
message = PyBytes_FromString(msg)
129131
try:
@@ -141,7 +143,7 @@ __geos_major_version__ = GEOS_VERSION_MAJOR
141143
# raise ValueError('version 2.2.3 of the geos library is required')
142144

143145
# intialize GEOS (parameters are notice and error function callbacks).
144-
initGEOS(notice_h, error_h)
146+
initGEOS(notice_h, <GEOSMessageHandler>error_h)
145147

146148
cdef class BaseGeometry:
147149
cdef GEOSGeometry *_geom

0 commit comments

Comments
 (0)