Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't build on GCC 14 #677

Open
lachesis opened this issue Nov 20, 2024 · 8 comments
Open

Can't build on GCC 14 #677

lachesis opened this issue Nov 20, 2024 · 8 comments

Comments

@lachesis
Copy link

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
Copy link
Author

lachesis commented Nov 20, 2024

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

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

@mikicz
Copy link

mikicz commented Jan 4, 2025

I managed a workaround, I updated the Makefiles, updated CFLAGS_BASE to have -Wno-incompatible-pointer-types and that got me past that error

@aamirglb
Copy link

@lachesis, @mikicz apart from the incompatible pointer type error, I also gets implicit declaration of function error for strndup

expand.c: In function 'expand_alternative_phrase_option':
expand.c:1502:36: error: implicit declaration of function 'strndup' [-Wimplicit-function-declaration]
 1502 |                 char *dupe_token = strndup(token + left_spaces, token_len - left_spaces - right_spaces);

numex.c: In function 'is_valid_roman_numeral':
numex.c:1216:18: error: implicit declaration of function 'strndup' [-Wimplicit-function-declaration]
 1216 |     char *copy = strndup(str, len);

To fix this issue, I manually #included strndup.h in those two files.

Did you get similar error while compiling the library?

My environment is MSYS2-MinGW64 with GCC 14.2.0

@mikicz
Copy link

mikicz commented Jan 14, 2025

Weirdly I didn't get that error!

@aamirglb
Copy link

@mikicz which environment are you using, Linux or MSYS2-MinGW64?

@mikicz
Copy link

mikicz commented Jan 14, 2025

I'm on Linux (Fedora 41)

@aamirglb
Copy link

It looks like strndup() is a POSIX function and available on all POSIX platform but it is not supported on MSYS2/Windows.

@snowfoxsh
Copy link

I had the same issue. Updating CFLAGS_BASE to include -Wno-incompatible-pointer-types. I am on Arch Linux.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants