librdkafka icon indicating copy to clipboard operation
librdkafka copied to clipboard

Avoid unused variable warnings for return values used only in assertions

Open chrisnovakovic opened this issue 3 years ago • 3 comments

The return values of many functions are assigned to variables for the sole purpose of using them in assertion conditions, which causes unused variable warnings to be emitted at compile-time when NDEBUG is defined. Use some compiler trickery in the definition of rd_assert() to avoid unused variable warnings when variables in the assertion condition are only used for that purpose, and ensure that assertions whose conditions contain single-use variables use rd_assert() instead of assert().

chrisnovakovic avatar Sep 08 '21 15:09 chrisnovakovic