zstd
zstd copied to clipboard
Disabled assert() could use its argument to avoid unused variable warnings
Test this construction for disabling assertions:
#define assert(condition) \
do { \
if (0) { \
(void)(condition); \
} \
} while (0)
Additionally, do the same for RAWLOG() and DEBUGLOG() when DEBUGLEVEL < 2.
This would avoid unused variable warnings that show up in production.
Note : this construction relies on the compiler doing a good DCE job. While this is most likely the case for most modern and mainstream compilers using optimization settings, it's more difficult to be sure about that with regards to the larger C compiler ecosystem.
An example of uncommon compiler (yet not completely fringe) which may have troubles with DCE could be tcc.