flintlib / flint

FLINT (Fast Library for Number Theory)
http://www.flintlib.org
GNU Lesser General Public License v3.0
401 stars 235 forks source link

ensure C99 compliance in headers, as 'I' is reserved #2027

Closed dimpase closed 1 week ago

dimpase commented 1 week ago

Including complex.h before flint headers leads to errors with modern compilers Note that the following code

#include <complex.h> /* save as t.c */
#include <flint/mpoly.h>

fails to compile with a suffciently new compiler, e.g. clang 16 or gcc 14.

$ gcc -c t.c
In file included from t.c:1:
/usr/include/flint/mpoly.h:1319:43: error: expected ‘)’ before ‘__extension__’
 1319 | void mpoly_gcd_info_init(mpoly_gcd_info_t I, slong nvars);
      |                                           ^
In file included from /usr/include/flint/fmpz_types.h:15,
                 from /usr/include/flint/fmpz_mod_types.h:15,
                 from /usr/include/flint/mpoly_types.h:15,
                 from /usr/include/flint/mpoly.h:23,
                 from t.c:2:
/usr/include/flint/mpoly.h:1319:46: error: expected ‘;’, ‘,’ or ‘)’ before ‘mp_limb_signed_t’
 1319 | void mpoly_gcd_info_init(mpoly_gcd_info_t I, slong nvars);
...

So the fix is to rename I to Iv in function declarations.

dimpase commented 1 week ago

in particular this issue prevents building Sage (sagelib) with numpy 2.0 (which includes complex.h)

albinahlback commented 1 week ago

Looks good to me, thanks!