Skip to content

build(warnings): enable -Wstrict-prototypes, -Wold-style-definition and -Wnested-externs - #959

Open
mohdTahaRafi wants to merge 2 commits into
metacall:developfrom
mohdTahaRafi:build/561-c-only-warnings
Open

mohdTahaRafi wants to merge 2 commits into
metacall:developfrom
mohdTahaRafi:build/561-c-only-warnings

Conversation

@mohdTahaRafi

Copy link
Copy Markdown

Description

This PR is a first step for #561. It enables three warnings from the commented-out list in cmake/Warnings.cmake. They only apply to C, and the code already has none of them, so they don't add any warnings now. They just stop new code from adding them.

  • -Wstrict-prototypes: a declaration like int f(); instead of int f(void);
  • -Wold-style-definition: old K&R style function definitions
  • -Wnested-externs: an extern declaration inside a function

Changes:

  • Uncommented the C-only flags line (CMAKE_C_FLAGS) with these three flags.
  • Moved -Wold-style-definition there from the add_compile_options() list, because that list is also used for C++ files, and GCC doesn't accept this flag for C++.
  • Left -Wmissing-prototypes commented on its own line. It still gives 9 warnings, so I'll fix those in a separate PR.

Testing: Full Debug builds with GCC 13 and Clang 18 (node, py, file, mock and ext loaders, the CLI, the sandbox plugins and the tests) give no new warnings, and the full ctest passes 108/108 with both compilers. The only warnings left are ones that were already there (Clang: the #560 warnings that #954 fixes; GCC: one -Wstrict-overflow in a C++ file).

Information:

  • I can't build the other loaders locally (rb, cs, java, wasm, rs, go, c, cob, rpc, ts) or test AppleClang, so CI needs to confirm those. MSVC isn't affected, since these flags are only set for GCC and Clang.

This PR also has the same CONTRIBUTORS commit as #954, because the pre-commit hook asks for it on a new branch. It's the same line, so it won't change anything when the second PR is merged.

No new dependencies.

Part of #561

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas. (nothing hard to understand, 2 lines of CMake)
  • I have made corresponding changes to the documentation. (nothing to change)
  • My changes generate no new warnings.
  • I have added tests/screenshots (if any) that prove my fix is effective or that my feature works. (build results above)
  • I have tested the tests implicated (if any) by my own code and they pass (make test or ctest -VV -R <test-name>). (full ctest, 108/108 with GCC and Clang)
  • If my change is significant or breaking, I have passed all tests with ./docker-compose.sh test &> output and attached the output. (not significant or breaking)
  • I have tested my code with OPTION_BUILD_ADDRESS_SANITIZER or ./docker-compose.sh test-address-sanitizer &> output and OPTION_TEST_MEMORYCHECK. (only compiler warning flags change, no code)
  • I have tested my code with OPTION_BUILD_THREAD_SANITIZER or ./docker-compose.sh test-thread-sanitizer &> output. (only compiler warning flags change, no code)
  • I have tested with Helgrind in case my code works with threading. (no threading)
  • I have run cmake --build build --target clang-format (or cmake -DMODE=fix -P cmake/Format.cmake) in order to format my code and my code follows the style guidelines. (no C/C++ files changed)
  • I have linked the Issue or Discussion with maintainer scope approval (community-first workflow, else the PR stays ignored). (Enable all compiler warnings and solve them (GCC, Clang, MSVC) #561 (comment))
  • I have disclosed AI assistance in the PR description (AI-ASSISTED: yes/no, model, human reviewer) and I own each line.

AI-ASSISTED: yes, Claude Opus 5.5, Reviewed and tested by me.

Enable -Wstrict-prototypes, -Wold-style-definition and -Wnested-externs
for C files. The code already builds without these warnings, so this
only stops new ones from being added.

Part of metacall#561
Copilot AI balanced review requested due to automatic review settings November 12, 2026 21:54

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

This branch has not been deployed

No deployments
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.

2 participants