diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4005fc14b..2275a2075 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -855,8 +855,7 @@ if(MSVC) endif() else() # GCC or compatible compilers such as Clang - set(WARNING_FLAGS "-Wall -Wextra") - set(WARNING_FLAGS "${WARNING_FLAGS} -Wno-unused-parameter") + set(WARNING_FLAGS "-Wall -Wextra -Wno-unused-parameter -Werror=vla") if(WARN_ALL) set(RELEASE_WARNING_FLAGS "${WARNING_FLAGS}") else() diff --git a/src/gui/modalMenu.cpp b/src/gui/modalMenu.cpp index f2ce5a5bf..0a130e905 100644 --- a/src/gui/modalMenu.cpp +++ b/src/gui/modalMenu.cpp @@ -291,13 +291,13 @@ bool GUIModalMenu::preprocessEvent(const SEvent &event) s32 selected_idx = dropdown->getSelected(); s32 option_size = dropdown->getItemCount(); - std::string list_of_options[option_size]; + std::vector list_of_options; for (s32 i = 0; i < option_size; i++) { - list_of_options[i] = wide_to_utf8(dropdown->getItem(i)); + list_of_options.push_back(wide_to_utf8(dropdown->getItem(i))); } - porting::showComboBoxDialog(list_of_options, option_size, selected_idx); + porting::showComboBoxDialog(list_of_options.data(), option_size, selected_idx); return true; // Prevent the Irrlicht dropdown from opening. } } diff --git a/src/porting_android.cpp b/src/porting_android.cpp index 47d8d3c1f..620d9d224 100644 --- a/src/porting_android.cpp +++ b/src/porting_android.cpp @@ -142,7 +142,7 @@ void showTextInputDialog(const std::string &hint, const std::string ¤t, in jhint, jcurrent, jeditType); } -void showComboBoxDialog(const std::string optionList[], s32 listSize, s32 selectedIdx) +void showComboBoxDialog(const std::string *optionList, s32 listSize, s32 selectedIdx) { jmethodID showdialog = jnienv->GetMethodID(activityClass, "showSelectionInputDialog", "([Ljava/lang/String;I)V"); diff --git a/src/porting_android.h b/src/porting_android.h index 64cf82ca8..86601f450 100644 --- a/src/porting_android.h +++ b/src/porting_android.h @@ -27,7 +27,7 @@ void showTextInputDialog(const std::string &hint, const std::string ¤t, in * @param listSize Size of the list * @param selectedIdx Selected index */ -void showComboBoxDialog(const std::string optionList[], s32 listSize, s32 selectedIdx); +void showComboBoxDialog(const std::string *optionList, s32 listSize, s32 selectedIdx); /** * Opens a share intent to the file at path