fixes include-order fragility across the msolve/libmsolve translation… - #360
Open
mohabsafey wants to merge 1 commit into
Open
fixes include-order fragility across the msolve/libmsolve translation…#360mohabsafey wants to merge 1 commit into
mohabsafey wants to merge 1 commit into
Conversation
… 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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)