From 058fb9fff02ba68d370ada918c72fab75f9d995c Mon Sep 17 00:00:00 2001 From: Misa Date: Thu, 28 Jul 2022 16:48:58 -0700 Subject: [PATCH] Fix warning: use of non-static data member initialization MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes the following warnings: desktop_version/src/Music.cpp: At global scope: desktop_version/src/Music.cpp:240:23: warning: non-static data member initializers only available with ‘-std=c++11’ or ‘-std=gnu++11’ [-Wc++11-extensions] 240 | Uint8 *wav_buffer = NULL; | ^ desktop_version/src/Music.cpp:414:32: warning: non-static data member initializers only available with ‘-std=c++11’ or ‘-std=gnu++11’ [-Wc++11-extensions] 414 | Uint8* decoded_buf_playing = NULL; | ^ desktop_version/src/Music.cpp:415:32: warning: non-static data member initializers only available with ‘-std=c++11’ or ‘-std=gnu++11’ [-Wc++11-extensions] 415 | Uint8* decoded_buf_reserve = NULL; | ^ desktop_version/src/Music.cpp:416:21: warning: non-static data member initializers only available with ‘-std=c++11’ or ‘-std=gnu++11’ [-Wc++11-extensions] 416 | Uint8* read_buf = NULL; | ^ These warnings are because the non-static data members (i.e. data members that will be different for each instance of a class) are being initialized at the same time as they're being declared, which means that's what their value will be when the class instance is initialized. However, this is only a C++11 feature, and we don't use C++11. Luckily, we don't need to do this, and this is in fact redundant because we already zero out the class instance in its constructor using SDL_zerop(). Therefore, we should remove these initializers to fix compliance with C++03. --- desktop_version/src/Music.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/desktop_version/src/Music.cpp b/desktop_version/src/Music.cpp index dfa0cef9..9de18024 100644 --- a/desktop_version/src/Music.cpp +++ b/desktop_version/src/Music.cpp @@ -237,7 +237,7 @@ end: } } - Uint8 *wav_buffer = NULL; + Uint8 *wav_buffer; Uint32 wav_length; FAudioWaveFormatEx format; bool valid; @@ -411,9 +411,9 @@ end: FAudioVoiceCallback callbacks; FAudioWaveFormatEx format; - Uint8* decoded_buf_playing = NULL; - Uint8* decoded_buf_reserve = NULL; - Uint8* read_buf = NULL; + Uint8* decoded_buf_playing; + Uint8* decoded_buf_reserve; + Uint8* read_buf; bool shouldloop; bool valid;