考虑以下两个宏:
#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, ... ) { \ …Run Code Online (Sandbox Code Playgroud)