Skip to content

Commit

Permalink
Fix compiler warnings on Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
csukuangfj committed Oct 19, 2023
1 parent 5dffe92 commit f04ceda
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
17 changes: 9 additions & 8 deletions sherpa-onnx/c-api/c-api.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions sherpa-onnx/csrc/offline-tts-vits-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ class OfflineTtsVitsImpl : public OfflineTtsImpl {
SHERPA_ONNX_LOGE(
"This is a single-speaker model and supports only sid 0. Given sid: "
"%d",
sid);
static_cast<int32_t>(sid));
return {};
}

if (num_speakers != 0 && (sid >= num_speakers || sid < 0)) {
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<int32_t>(sid));
return {};
}

Expand Down

0 comments on commit f04ceda

Please sign in to comment.