recently I'm studying a project in github,and I found this.why there is a "(void)n" in the end?
void CurrentThread::cacheTid()
{
if (t_cachedTid == 0)
{
t_cachedTid = detail::gettid();
int n = snprintf(t_tidString, sizeof t_tidString, "%5d ", t_cachedTid);
assert(n == 6); (void) n;
}
}
(void)n is effectively a no-op. However, it will prevent the compiler from issuing an "unused variable" warning when assertions are turned off and the preceding assert() is compiled out.
This construction suppresses warning about declared, but never used variable
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With