mirror of
https://github.com/google/brotli.git
synced 2026-07-08 17:56:58 +00:00
Compiler warnings #370
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @crazydef on GitHub (Jan 5, 2021).
Hi,
When including Brotli headers in our own projects, we're experiencing the following compiler warnings in Visual Studio 2019:
brotli\dec\bit_reader.h(27,47): warning C4127: conditional expression is constant
brotli\dec\bit_reader.h(110,74): warning C4127: conditional expression is constant
brotli\dec\bit_reader.h(119,75): warning C4127: conditional expression is constant
brotli\dec\bit_reader.h(108,41): warning C4100: 'n_bits': unreferenced formal parameter
brotli\dec\bit_reader.h(252,39): warning C4127: conditional expression is constant
brotli\dec\bit_reader.h(272,39): warning C4127: conditional expression is constant
brotli\dec\bit_reader.h(307,39): warning C4127: conditional expression is constant
brotli\dec\bit_reader.h(27,47): warning C4127: conditional expression is constant
brotli\dec\bit_reader.h(110,74): warning C4127: conditional expression is constant
brotli\dec\bit_reader.h(119,75): warning C4127: conditional expression is constant
brotli\dec\bit_reader.h(108,41): warning C4100: 'n_bits': unreferenced formal parameter
brotli\dec\bit_reader.h(252,39): warning C4127: conditional expression is constant
brotli\dec\bit_reader.h(272,39): warning C4127: conditional expression is constant
brotli\dec\bit_reader.h(307,39): warning C4127: conditional expression is constant
brotli\dec\huffman.c(124,1): warning C4127: conditional expression is constant
brotli\dec\huffman.c(135,1): warning C4127: conditional expression is constant
brotli\dec\decode.c(1174,7): warning C4127: conditional expression is constant
It'd be nice if we didn't see these in the future. :)
@eustas commented on GitHub (Jan 18, 2021):
brotli\dec\bit_reader.h(108,41): warning C4100: 'n_bits': unreferenced formal parametercould be fixed.Others are just compiler suspicions - it is explicit that we expect "compile-time-constant" conditional expression there, to gain performance on different platforms / targets. So, you should consider suppressing warning 4127 via command line parameters.
@crazydef commented on GitHub (Jan 18, 2021):
If they're expected, you should be suppressing them.
Taking the following as an example, it would be better (in my opinion) to do something like this anyway:
We're not so relaxed about suppressing compiler warnings in our code and it would be nice to not have to constantly play catch up when someone includes your headers in a new part of our code.
@eustas commented on GitHub (Jan 18, 2021):
We also do care about code quality and eliminate warnings.
But here problem is not with
BROTLI_IS_CONSTANTmacro; it is about compiler being picky.When MSVC adds support for
__builtin_constant_pthe code snippet you have provided will also generate warning, becauseBROTLI_IS_CONSTANT(x)has (instance-wise) constant value.If we look at warning in
huffman.c- compiler does not like howBROTLI_REPEATmacro works:I hope we would be able to find a solution that will calm down MSVC...
@crazydef commented on GitHub (Jan 18, 2021):
Microsoft will almost definitely never add support for that. The Visual Studio compiler is a C++ compiler that happens to have some limited support for older versions of C. In C++ there are better, standard ways to do this.
@eustas commented on GitHub (Jan 3, 2023):
BROTLI_REPEATwas unwrapped. Will check soon what remaining warnings we have and fix them.