From 425da583009b737f858a0b29fd4101980130f591 Mon Sep 17 00:00:00 2001 From: Ghabry Date: Mon, 2 Sep 2024 15:41:49 +0200 Subject: [PATCH] Cast the string constants to char* when tremor is used. Fixes warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings] Tremor never writes to the strings so this is safe to do. --- src/decoder_oggvorbis.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/decoder_oggvorbis.cpp b/src/decoder_oggvorbis.cpp index ddf1716581..1a69564fa6 100644 --- a/src/decoder_oggvorbis.cpp +++ b/src/decoder_oggvorbis.cpp @@ -92,21 +92,29 @@ bool OggVorbisDecoder::Open(Filesystem_Stream::InputStream stream) { vorbis_comment* vc = ov_comment(ovf, -1); if (vc) { // RPG VX loop support - const char* str = vorbis_comment_query(vc, "LOOPSTART", 0); + // Workaround conversion of string constant to char warning because + // of tremor using a different signature. +#if defined(HAVE_TREMOR) + using char_type = char*; +#else + using char_type = const char*; +#endif + + const char* str = vorbis_comment_query(vc, (char_type)"LOOPSTART", 0); if (str) { auto total = ov_pcm_total(ovf, -1) ; loop.start = std::min(atoi(str), total); if (loop.start >= 0) { loop.looping = true; loop.end = total; - str = vorbis_comment_query(vc, "LOOPLENGTH", 0); + str = vorbis_comment_query(vc, (char_type)"LOOPLENGTH", 0); if (str) { int len = atoi(str); if (len >= 0) { loop.end = std::min(loop.start + len, total); } } else { - str = vorbis_comment_query(vc, "LOOPEND", 0); + str = vorbis_comment_query(vc, (char_type)"LOOPEND", 0); if (str) { int end = atoi(str); if (end >= 0) {