Skip to content

Enable shadow warnings and optional warnings-as-errors (#531) - #535

Open
vaezim wants to merge 3 commits into
machinezone:masterfrom
vaezim:master
Open

vaezim wants to merge 3 commits into
machinezone:masterfrom
vaezim:master

Conversation

@vaezim

@vaezim vaezim commented Dec 8, 2024 •

Copy link
Copy Markdown

IXWebSocket and the CLI could not be built with -Werror -Wshadow because local variables hid request streams, error variables, lock guards, CLI options, and the Network.framework receive-error field.

Update the shadow-warning cleanup for current master and remove unused outer streams. Apply compiler warnings privately to ixwebsocket and ws, with IXWEBSOCKET_WARNINGS_AS_ERRORS off by default. This avoids imposing fatal warnings on normal builds, vendored dependencies, or consumers. Unix GCC/Clang builds enable -Wshadow; the redundant explicit -Wunused flag is unnecessary alongside -Wall -Wextra.

Linux CI now runs make -f makefile.dev test WARNINGS_AS_ERRORS=ON, which also builds the CLI. The normal make target keeps warnings nonfatal. Document the CMake option and developer command.

Merged current master and resolved the HTTP-server and transport conflicts, preserving the case-insensitive Upgrade handling, stable TLS pending-write batches, and recent close-state fixes. Production code remains C++11 compatible.

Closes #531.

Validation:

  • Strict Clang/OpenSSL build: full suite 25/25 passing.
  • Strict Linux GCC build without TLS/zlib: full suite 22/22 passing; GCC unity library/CLI build also passes.
  • Strict Mbed TLS and Network.framework library/CLI builds pass; Network.framework integration test passes.
  • MinGW cross-build of the library and CLI passes.
  • Embedded CMake consumer builds and runs with strict library warnings enabled; its sibling dependency's deliberate shadow warning remains nonfatal. Checked that strict flags are absent from vendored Catch2 and the library's exported compile options, and warnings-as-errors is disabled by default.
  • Formatting and git diff --check pass.

@rh101

rh101 commented Dec 8, 2024 •

Copy link
Copy Markdown
Contributor

@vaezim It looks like you accidentally changed code completely unrelated to the -Werror -Wshadow compiler flags. There shouldn't be underscores at the start of all those variable names.

@vaezim

vaezim commented Dec 8, 2024

Copy link
Copy Markdown
Author

@vaezim It looks like you accidentally changed code completely unrelated to the -Werror -Wshadow compiler flags. There shouldn't be underscores at the start of all those variable names.

Those variables were shadowed by another variable in the outer scopes. Either outer scope variable or local ones needed renaming. Do you have other solutions? we can clear the outer one and reuse it.

@rh101

rh101 commented Dec 8, 2024 •

Copy link
Copy Markdown
Contributor

Those variables were shadowed by another variable in the outer scopes. Either outer scope variable or local ones needed renaming. Do you have other solutions? we can clear the outer one and reuse it.

If that's the case, then it would be best to rename them to something more appropriate, without the underscore prefix, since by convention that makes them appear as class member variables, which they are not.

If it is possible to re-use the outer-scope variables, then that is also a solution, but all code paths should be considered to ensure it is safe to re-use them.

@vaezim

vaezim commented Dec 8, 2024

Copy link
Copy Markdown
Author

Removed underscores and renamed according to scope context.

@bsergean bsergean changed the title Add -Werror -Wshadow compiler flags to CMAKE_CXX_FLAGS (#531) Enable shadow warnings and optional warnings-as-errors (#531) Nov 9, 2026

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.

Add -Werror -Wshadow compiler flag

3 participants