diff --git a/dlib/dnn/cublas_dlibapi.cpp b/dlib/dnn/cublas_dlibapi.cpp index 9273280c9..3a2d79d2b 100644 --- a/dlib/dnn/cublas_dlibapi.cpp +++ b/dlib/dnn/cublas_dlibapi.cpp @@ -25,7 +25,7 @@ static const char* cublas_get_error_string(cublasStatus_t s) // Check the return value of a call to the cuBLAS runtime for an error condition. #define CHECK_CUBLAS(call) \ -{ \ +do{ \ const cublasStatus_t error = call; \ if (error != CUBLAS_STATUS_SUCCESS) \ { \ @@ -34,7 +34,7 @@ static const char* cublas_get_error_string(cublasStatus_t s) sout << "code: " << error << ", reason: " << cublas_get_error_string(error);\ throw dlib::cublas_error(sout.str()); \ } \ -} +}while(false) namespace dlib { diff --git a/dlib/dnn/cudnn_dlibapi.cpp b/dlib/dnn/cudnn_dlibapi.cpp index bff63478c..fe61ca715 100644 --- a/dlib/dnn/cudnn_dlibapi.cpp +++ b/dlib/dnn/cudnn_dlibapi.cpp @@ -36,7 +36,7 @@ static const char* cudnn_get_error_string(cudnnStatus_t s) // Check the return value of a call to the cuDNN runtime for an error condition. #define CHECK_CUDNN(call) \ -{ \ +do{ \ const cudnnStatus_t error = call; \ if (error != CUDNN_STATUS_SUCCESS) \ { \ @@ -45,7 +45,7 @@ static const char* cudnn_get_error_string(cudnnStatus_t s) sout << "code: " << error << ", reason: " << cudnn_get_error_string(error);\ throw dlib::cudnn_error(sout.str()); \ } \ -} +}while(false) namespace dlib diff --git a/dlib/dnn/curand_dlibapi.cpp b/dlib/dnn/curand_dlibapi.cpp index 170988cce..698bfd0e8 100644 --- a/dlib/dnn/curand_dlibapi.cpp +++ b/dlib/dnn/curand_dlibapi.cpp @@ -24,7 +24,7 @@ static const char* curand_get_error_string(curandStatus_t s) // Check the return value of a call to the cuDNN runtime for an error condition. #define CHECK_CURAND(call) \ -{ \ +do{ \ const curandStatus_t error = call; \ if (error != CURAND_STATUS_SUCCESS) \ { \ @@ -33,7 +33,7 @@ static const char* curand_get_error_string(curandStatus_t s) sout << "code: " << error << ", reason: " << curand_get_error_string(error);\ throw dlib::curand_error(sout.str()); \ } \ -} +}while(false) namespace dlib {