考虑以下两个宏:
#define PNORM( v, s, ... ) { \
if( VERBOSITY_CHECK( v ) ) { \
if( ( errno = pthread_mutex_lock(&server.output_mutex) ) ) { \
PERROR_LOCKFREE( normal, "\tpthread_mutex_lock failed on output_mutex.\r\n" ) ; \
} \
fprintf( stdout, s, ## __VA_ARGS__ ) ; \
fflush( stdout ) ; \
if( ( errno = pthread_mutex_unlock(&server.output_mutex) ) ) { \
PERROR_LOCKFREE( normal, "\tpthread_mutex_unlock failed on output_mutex.\r\n" ) ; \
} \
} \
}
#define PERROR_LOCKFREE( v, s, ... ) { \
if( VERBOSITY_CHECK( v ) ) { \
PERRNO ;\
fprintf( stderr, s, ## __VA_ARGS__ ) ; \
fflush( stderr ) ; \
} \
}
现在考虑使用这些的示例:
PNORM( verbose, "\tSomeText [%d] More [%p]\r\n", 0, ptr ) ;
当使用 -pedantic 选项和 -std=c99 编译时,我多次收到此错误:
mycode.c:410:112: warning: ISO C99 requires rest arguments to be used
编译器对此的抱怨是正确的,但有没有一种简单的方法可以抑制这个警告,因为我不关心它?