GCC: How To Suppress a Warning in a Single Line of Code
TIL that GCC allows to suppress a given type of warnings in a single line of code. Here is an example:
InMemoryStorage::InMemoryStorage() {
if(pthread_rwlock_init(&_rwlock, NULL) != 0)
throw std::runtime_error("pthread_rwlock_init() failed");
}
InMemoryStorage::~InMemoryStorage() {
if(pthread_rwlock_destroy(&_rwlock) != 0) {
// suppress 'throw will always call terminate() [-Wterminate]'
#pragma GCC diagnostic push …