]> git.ipfire.org Git - thirdparty/libsolv.git/commitdiff
Fix building in ISO C23 580/head
authorPetr Písař <ppisar@redhat.com>
Fri, 7 Feb 2025 14:21:16 +0000 (15:21 +0100)
committerPetr Písař <ppisar@redhat.com>
Fri, 7 Feb 2025 14:39:51 +0000 (15:39 +0100)
ISO C23 added bool type as a keyword. It is the standard GCC 15 uses by default and
compilation of bindings/perl/solv_perl.c fails then:

    bindings/perl/solv_perl.c:1641:13: error: ‘bool’ cannot be defined via ‘typedef’
     1641 | typedef int bool;
  |             ^~~~
    /home/test/fedora/libsolv/libsolv-0.7.31-build/libsolv-0.7.31/redhat-linux-build/bindings/perl/solv_perl.c:1641:13: note: ‘bool’ is a keyword with ‘-std=c23’ onwards
    /home/test/fedora/libsolv/libsolv-0.7.31-build/libsolv-0.7.31/redhat-linux-build/bindings/perl/solv_perl.c:1641:1: warning: useless type name in empty declaration
     1641 | typedef int bool;
  | ^~~~~~~

The typedef comes from bindings/solv.i which attemps to supply it in case Swig
undefines it.

This patch fixes it by not defining it in case ISO C23 or newer is in
use. Keywords cannot be checked by a preprocessor, neither undefined
(by Swig).

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2340762

bindings/solv.i

index 3b61ab04b7c8cae54bb5f69694db44a02c60b0ea..8d46a2d3aeafefa2f8ea549034f9ce65b444a7f4 100644 (file)
@@ -976,8 +976,10 @@ SWIG_AsValDepId(void *obj, int *val) {
 
 /* argh, swig undefs bool for perl */
 #ifndef bool
+#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 202311L
 typedef int bool;
 #endif
+#endif
 
 #include "pool.h"
 #include "poolarch.h"