From f04ceda9ffe28ff9fad855a4fbafe447de294fa7 Mon Sep 17 00:00:00 2001 From: Fangjun Kuang Date: Thu, 19 Oct 2023 10:41:54 +0800 Subject: [PATCH] Fix compiler warnings on Linux --- sherpa-onnx/c-api/c-api.h | 17 +++++++++-------- sherpa-onnx/csrc/offline-tts-vits-impl.h | 4 ++-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/sherpa-onnx/c-api/c-api.h b/sherpa-onnx/c-api/c-api.h index b4b5780a9..05b79a806 100644 --- a/sherpa-onnx/c-api/c-api.h +++ b/sherpa-onnx/c-api/c-api.h @@ -22,6 +22,11 @@ extern "C" { // We will set SHERPA_ONNX_BUILD_SHARED_LIBS and SHERPA_ONNX_BUILD_MAIN_LIB in // CMakeLists.txt +#if defined(__GNUC__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wattributes" +#endif + #if defined(_WIN32) #if defined(SHERPA_ONNX_BUILD_SHARED_LIBS) #define SHERPA_ONNX_EXPORT __declspec(dllexport) @@ -31,15 +36,7 @@ extern "C" { #define SHERPA_ONNX_IMPORT #endif #else // WIN32 -#if __APPLE__ -// it throws a warning on macOS when using -// __attribute__((visibility("default"))) -// -// warning: 'visibility' attribute ignored [-Wignored-attributes] -#define SHERPA_ONNX_EXPORT -#else #define SHERPA_ONNX_EXPORT __attribute__((visibility("default"))) -#endif // __APPLE__ #define SHERPA_ONNX_IMPORT SHERPA_ONNX_EXPORT #endif // WIN32 @@ -598,6 +595,10 @@ SHERPA_ONNX_API void SherpaOnnxDestroySpeechSegment( SHERPA_ONNX_API void SherpaOnnxVoiceActivityDetectorReset( SherpaOnnxVoiceActivityDetector *p); +#if defined(__GNUC__) +#pragma GCC diagnostic pop +#endif + #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/sherpa-onnx/csrc/offline-tts-vits-impl.h b/sherpa-onnx/csrc/offline-tts-vits-impl.h index b553ebe4a..af1a001eb 100644 --- a/sherpa-onnx/csrc/offline-tts-vits-impl.h +++ b/sherpa-onnx/csrc/offline-tts-vits-impl.h @@ -30,7 +30,7 @@ class OfflineTtsVitsImpl : public OfflineTtsImpl { SHERPA_ONNX_LOGE( "This is a single-speaker model and supports only sid 0. Given sid: " "%d", - sid); + static_cast(sid)); return {}; } @@ -38,7 +38,7 @@ class OfflineTtsVitsImpl : public OfflineTtsImpl { SHERPA_ONNX_LOGE( "This model contains only %d speakers. sid should be in the range " "[%d, %d]. Given: %d", - num_speakers, 0, num_speakers - 1, sid); + num_speakers, 0, num_speakers - 1, static_cast(sid)); return {}; }