Skip to content

Fix compilation errors on modern C compilers and CMake >= 3.28#185

Open
ludomal wants to merge 1 commit into
openitu:devfrom
ludomal:fix/compilation-errors
Open

Fix compilation errors on modern C compilers and CMake >= 3.28#185
ludomal wants to merge 1 commit into
openitu:devfrom
ludomal:fix/compilation-errors

Conversation

@ludomal
Copy link
Copy Markdown
Member

@ludomal ludomal commented May 31, 2026

This PR fixes compilation errors that prevent the STL from building with modern C compilers (Clang 17+, GCC 14+) and CMake >= 3.28.

Changes

CMake version policy (CMakeLists.txt, src/wmc_tool/CMakeLists.txt)

CMake 3.28+ removed compatibility with cmake_minimum_required(VERSION) values below 3.5. The previous VERSION 3.1 caused a fatal configuration error:

Compatibility with CMake < 3.5 has been removed from CMake.

Updated to use the range syntax VERSION 3.10...3.31:

  • The minimum (3.10) ensures broad compatibility with systems still running older CMake (e.g., Ubuntu 20.04 ships 3.16).
  • The maximum (3.31) tells CMake which policy version the project has been tested against, preventing unexpected policy changes from newer CMake versions.
  • This is the CMake-recommended approach for projects that need to support a range of CMake versions.

src/g711/shiftbit.c - incompatible pointer to integer conversion

fread() was called with fi (an int file descriptor from fileno()) instead of Fi (the FILE * from fopen()). This was introduced when migrating from POSIX read() to fread() but the argument was not updated.

src/mnru/mnru.c - incompatible integer to pointer conversion

s->seed is declared as long but was assigned NULL (a pointer type). Changed to 0.

src/unsup/endian.c - implicit int return type

reverse_endian_short() and reverse_endian_long() had no return type specifier, which defaults to int (invalid in C99 and later). Added explicit void return types. Also fixed signedness mismatch in test_s()/test_l() local variables.

Testing

Successfully compiled and linked (100% targets) on:

  • macOS 26 (arm64) with Apple Clang 17, CMake 4.0.2
  • Ubuntu 24 (x86_64) with GCC/Clang, CMake 3.28.3

No functional changes (only type corrections and CMake version policy update).

- CMakeLists.txt, src/wmc_tool/CMakeLists.txt: Update cmake_minimum_required
  to VERSION 3.10...3.31 (range syntax required by CMake >= 3.28)
- shiftbit.c: Pass FILE* (Fi) instead of int fd (fi) to fread()
- mnru.c: Assign 0 instead of NULL to long field s->seed
- endian.c: Add void return types to reverse_endian_short/long,
  use unsigned types in test functions to match signatures
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