Skip to content

fixes include-order fragility across the msolve/libmsolve translation… - #360

Open
mohabsafey wants to merge 1 commit into
algebraic-solving:masterfrom
mohabsafey:fixes-alphabetical-order
Open

fixes include-order fragility across the msolve/libmsolve translation…#360
mohabsafey wants to merge 1 commit into
algebraic-solving:masterfrom
mohabsafey:fixes-alphabetical-order

Conversation

@mohabsafey

Copy link
Copy Markdown
Contributor

Several .c files are textually #included into one translation unit (via msolve.c and libmsolve.c) and silently relied on being processed in a specific order to see functions/macros/types defined by files included later or listed elsewhere. Reordering those #include lines (e.g. an editor auto-formatter alphabetizing them) broke the build with implicit-declaration/conflicting-type errors.

Forward-declare the cross-file functions involved (msolve.c's duplicate.c/linear.c/lifting.c/lifting-gb.c block; libmsolve.c's display_monomial_full and next_prime), and have iofiles.c, hilbert.c, msolve-data.c and mpq_reconstruct.c include msolve-data.h themselves instead of relying on an earlier file to have pulled it in.

Also fixes crt/mpz_CRT_ui.c's vendored ulong_extras.h, which only avoided its own broken "ulong_extras/ll_mod_preinv.c" include by accident: it shares FLINT's ULONG_EXTRAS_H include guard, so it only worked as long as hilbert.c (via fglm) happened to pull in the real flint/ulong_extras.h first. Now includes the real header directly so the guard is always pre-empted regardless of #include order elsewhere.

Verified by fully alphabetizing both include blocks and rebuilding; all 65 tests still pass with the real, unmodified source.

I prepared this using claude code (sonnet 5)

… unit

Several .c files are textually #included into one translation unit
(via msolve.c and libmsolve.c) and silently relied on being processed
in a specific order to see functions/macros/types defined by files
included later or listed elsewhere. Reordering those #include lines
(e.g. an editor auto-formatter alphabetizing them) broke the build
with implicit-declaration/conflicting-type errors.

Forward-declare the cross-file functions involved (msolve.c's
duplicate.c/linear.c/lifting.c/lifting-gb.c block; libmsolve.c's
display_monomial_full and next_prime), and have iofiles.c, hilbert.c,
msolve-data.c and mpq_reconstruct.c include msolve-data.h themselves
instead of relying on an earlier file to have pulled it in.

Also fixes crt/mpz_CRT_ui.c's vendored ulong_extras.h, which only
avoided its own broken "ulong_extras/ll_mod_preinv.c" include by
accident: it shares FLINT's ULONG_EXTRAS_H include guard, so it only
worked as long as hilbert.c (via fglm) happened to pull in the real
flint/ulong_extras.h first. Now includes the real header directly so
the guard is always pre-empted regardless of #include order elsewhere.

Verified by fully alphabetizing both include blocks and rebuilding;
all 65 tests still pass with the real, unmodified source.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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

Successfully merging this pull request may close these issues.

1 participant