fix(build): Address various compiler warnings (ULL, const-correctness, Wformat) #1530
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.
Description of Change
Summary
This Pull Request addresses several compiler warnings found when compiling the repository with strict compiler flags (e.g., Clang 17.0.0 on macOS, which uses -Wall). These changes ensure better code quality, portability, and adherence to modern C standards without altering the functionality of the algorithms.
Specific Warnings Fixed
-Wimplicitly-unsigned-literal):ULLsuffix to large constants indecimal_to_any_base.candhash_djb2.c.-Wabsolute-value):fabsfto the double-precision functionfabsingeometry/vectors_3d.cbecause the variablealphais of typedouble.-Wincompatible-pointer-types-discards-qualifiers):(const int **)in themainfunction ofmodified_binary_search.cto match the function signature, resolving the const-discarding warning.-Wformat):scanfincollatz.cto%lluto correctly read into auint64_t.printfformat specifier inshell_sort2.cfrom%.4g(double) to%.4lu(unsigned long) for printingclock_tdifferences.prime_factoriziation.c(C99 style initialization inside theforloop).Thank you for reviewing!
Checklist
Notes: