openvenues / libpostal

A C library for parsing/normalizing street addresses around the world. Powered by statistical NLP and open geo data.
MIT License
4.08k stars 421 forks source link

Can't build on GCC 14 #677

Open lachesis opened 5 days ago

lachesis commented 5 days ago

Hi!

I was checking out libpostal, and saw something that could be improved.


My country is USA


Here's how I'm using libpostal

I'm trying to canonicalize addresses.


Here's what I did

make


Here's what I got

$ make
make[2]: Entering directory '/home/user/projects/libpostal/libpostal/src'
/bin/sh ../libtool  --tag=CC   --mode=compile gcc -DHAVE_CONFIG_H -I.. -I/usr/local/include    -Wall -Wextra -Wno-unused-function -Wformat -Werror=format-security -Winit-self -Wno-sign-compare -DLIBPOSTAL_DATA_DIR='"/home/user/projects/libpostal/libpostal_data/libpostal"' -g -mfpmath=sse -msse2 -DUSE_SSE -g -O2 -O2 -D LIBPOSTAL_EXPORTS  -MT libpostal_la-libpostal.lo -MD -MP -MF .deps/libpostal_la-libpostal.Tpo -c -o libpostal_la-libpostal.lo `test -f 'libpostal.c' || echo './'`libpostal.c
libtool: compile:  gcc -DHAVE_CONFIG_H -I.. -I/usr/local/include -Wall -Wextra -Wno-unused-function -Wformat -Werror=format-security -Winit-self -Wno-sign-compare -DLIBPOSTAL_DATA_DIR=\"/home/user/projects/libpostal/libpostal_data/libpostal\" -g -mfpmath=sse -msse2 -DUSE_SSE -g -O2 -O2 -D LIBPOSTAL_EXPORTS -MT libpostal_la-libpostal.lo -MD -MP -MF .deps/libpostal_la-libpostal.Tpo -c libpostal.c  -fPIC -DPIC -o .libs/libpostal_la-libpostal.o
libpostal.c: In function ‘libpostal_classify_language’:
libpostal.c:217:58: error: initialization of ‘libpostal_language_classifier_response_t *’ {aka ‘struct libpostal_language_classifier_response *’} from incompatible pointer type ‘language_classifier_response_t *’ {aka ‘struct language_classifier_response *’} [-Wincompatible-pointer-types]
  217 |     libpostal_language_classifier_response_t *response = classify_languages(address);
      |                                                          ^~~~~~~~~~~~~~~~~~
make[2]: *** [Makefile:1417: libpostal_la-libpostal.lo] Error 1
make[2]: Leaving directory '/home/user/projects/libpostal/libpostal/src'
make[1]: *** [Makefile:470: all-recursive] Error 1
make[1]: Leaving directory '/home/user/projects/libpostal/libpostal'
make: *** [Makefile:379: all] Error 2

$ gcc --version
gcc (GCC) 14.2.1 20240910
Copyright (C) 2024 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Here's what I was expecting

The package to build successfully.


For parsing issues, please answer "yes" or "no" to all that apply.

Does not apply.


Here's what I think could be improved

GCC no longer allows implicitly casting all pointer types to all other pointer types. This behavior is now restricted to the void * type and its qualified variations.

https://gcc.gnu.org/gcc-14/porting_to.html

Instead, libpostal should probably just export the other type.

lachesis commented 5 days ago

Alternatively, you could explicitly cast with a void* in the way:

libpostal_language_classifier_response_t *response = (void*)classify_languages(address);