[PR #1530] [CLOSED] fix(build): Address various compiler warnings (ULL, const-correctness, Wformat) #2139

Closed
opened 2026-01-29 15:29:24 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/TheAlgorithms/C/pull/1530
Author: @jesper-olsen
Created: 11/18/2025
Status: Closed

Base: masterHead: fix/compiler-warnings


📝 Commits (1)

  • 7fe7f16 fix(build): Address various compiler warnings (ULL, const-correctness, Wformat)

📊 Changes

2596 files changed (+139413 additions, -11 deletions)

View changed files

CMakeCache.txt (+576 -0)
CMakeFiles/4.1.1/CMakeCCompiler.cmake (+84 -0)
CMakeFiles/4.1.1/CMakeDetermineCompilerABI_C.bin (+0 -0)
CMakeFiles/4.1.1/CMakeSystem.cmake (+15 -0)
CMakeFiles/4.1.1/CompilerIdC/CMakeCCompilerId.c (+934 -0)
CMakeFiles/4.1.1/CompilerIdC/apple-sdk.c (+1 -0)
CMakeFiles/CMakeConfigureLog.yaml (+3270 -0)
CMakeFiles/CMakeDirectoryInformation.cmake (+16 -0)
CMakeFiles/InstallScripts.json (+25 -0)
CMakeFiles/Makefile.cmake (+362 -0)
CMakeFiles/Makefile2 (+7166 -0)
CMakeFiles/TargetDirectories.txt (+344 -0)
CMakeFiles/cmake.check_cache (+1 -0)
CMakeFiles/progress.marks (+1 -0)
CPackConfig.cmake (+82 -0)
CPackSourceConfig.cmake (+90 -0)
Makefile (+2899 -0)
audio/CMakeFiles/CMakeDirectoryInformation.cmake (+16 -0)
audio/CMakeFiles/alaw.dir/DependInfo.cmake (+23 -0)
audio/CMakeFiles/alaw.dir/alaw.c.o (+0 -0)

...and 80 more files

📄 Description

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

  1. Implicit Unsigned Literals (-Wimplicitly-unsigned-literal):
    • Fixed by adding the ULL suffix to large constants in decimal_to_any_base.c and hash_djb2.c.
  2. Double/Float Mismatch (-Wabsolute-value):
    • Changed fabsf to the double-precision function fabs in geometry/vectors_3d.c because the variable alpha is of type double.
  3. Const-Correctness (-Wincompatible-pointer-types-discards-qualifiers):
    • Applied an explicit cast (const int **) in the main function of modified_binary_search.c to match the function signature, resolving the const-discarding warning.
  4. Format Mismatch (-Wformat):
    • Corrected the format specifier for scanf in collatz.c to %llu to correctly read into a uint64_t.
    • Corrected the printf format specifier in shell_sort2.c from %.4g (double) to %.4lu (unsigned long) for printing clock_t differences.
  5. Misc:
    • Simplified array iteration initialization in prime_factoriziation.c (C99 style initialization inside the for loop).

Thank you for reviewing!

Checklist

  • Added description of change
  • PR title follows semantic commit guidelines
  • Search previous suggestions before making a new one, as yours may be a duplicate.
  • I acknowledge that all my contributions will be made under the project's license.

Notes:


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/TheAlgorithms/C/pull/1530 **Author:** [@jesper-olsen](https://github.com/jesper-olsen) **Created:** 11/18/2025 **Status:** ❌ Closed **Base:** `master` ← **Head:** `fix/compiler-warnings` --- ### 📝 Commits (1) - [`7fe7f16`](https://github.com/TheAlgorithms/C/commit/7fe7f16e992d0b27695578cef34c79fabd5c4913) fix(build): Address various compiler warnings (ULL, const-correctness, Wformat) ### 📊 Changes **2596 files changed** (+139413 additions, -11 deletions) <details> <summary>View changed files</summary> ➕ `CMakeCache.txt` (+576 -0) ➕ `CMakeFiles/4.1.1/CMakeCCompiler.cmake` (+84 -0) ➕ `CMakeFiles/4.1.1/CMakeDetermineCompilerABI_C.bin` (+0 -0) ➕ `CMakeFiles/4.1.1/CMakeSystem.cmake` (+15 -0) ➕ `CMakeFiles/4.1.1/CompilerIdC/CMakeCCompilerId.c` (+934 -0) ➕ `CMakeFiles/4.1.1/CompilerIdC/apple-sdk.c` (+1 -0) ➕ `CMakeFiles/CMakeConfigureLog.yaml` (+3270 -0) ➕ `CMakeFiles/CMakeDirectoryInformation.cmake` (+16 -0) ➕ `CMakeFiles/InstallScripts.json` (+25 -0) ➕ `CMakeFiles/Makefile.cmake` (+362 -0) ➕ `CMakeFiles/Makefile2` (+7166 -0) ➕ `CMakeFiles/TargetDirectories.txt` (+344 -0) ➕ `CMakeFiles/cmake.check_cache` (+1 -0) ➕ `CMakeFiles/progress.marks` (+1 -0) ➕ `CPackConfig.cmake` (+82 -0) ➕ `CPackSourceConfig.cmake` (+90 -0) ➕ `Makefile` (+2899 -0) ➕ `audio/CMakeFiles/CMakeDirectoryInformation.cmake` (+16 -0) ➕ `audio/CMakeFiles/alaw.dir/DependInfo.cmake` (+23 -0) ➕ `audio/CMakeFiles/alaw.dir/alaw.c.o` (+0 -0) _...and 80 more files_ </details> ### 📄 Description #### 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** 1. **Implicit Unsigned Literals (`-Wimplicitly-unsigned-literal`):** * Fixed by adding the `ULL` suffix to large constants in `decimal_to_any_base.c` and `hash_djb2.c`. 2. **Double/Float Mismatch (`-Wabsolute-value`):** * Changed `fabsf` to the double-precision function `fabs` in `geometry/vectors_3d.c` because the variable `alpha` is of type `double`. 3. **Const-Correctness (`-Wincompatible-pointer-types-discards-qualifiers`):** * Applied an explicit cast `(const int **)` in the `main` function of `modified_binary_search.c` to match the function signature, resolving the const-discarding warning. 4. **Format Mismatch (`-Wformat`):** * Corrected the format specifier for `scanf` in `collatz.c` to `%llu` to correctly read into a `uint64_t`. * Corrected the `printf` format specifier in `shell_sort2.c` from `%.4g` (double) to `%.4lu` (unsigned long) for printing `clock_t` differences. 5. **Misc:** * Simplified array iteration initialization in `prime_factoriziation.c` (C99 style initialization inside the `for` loop). Thank you for reviewing! #### Checklist <!-- Remove items that do not apply. For completed items, change [ ] to [x]. --> - [x] Added description of change - [x] PR title follows semantic [commit guidelines](https://github.com/TheAlgorithms/C/blob/master/CONTRIBUTING.md#Commit-Guidelines) - [x] Search previous suggestions before making a new one, as yours may be a duplicate. - [x] I acknowledge that all my contributions will be made under the project's license. Notes: <!-- Please add a one-line description for developers or pull request viewers --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-29 15:29:24 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/C#2139