summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2023-02-01 16:12:58 +1100
committer Vas Crabb <vas@vastheman.com>2023-02-01 16:12:58 +1100
commit0ae68e4dea29dd55338bc829b72a67d2f59debf7 (patch)
tree190c54185700cb5b2444b27cfbe58dd4b443da3a
parentc4830168a56953af9714907664ceee72999df70c (diff)
Use EQUIVALENT_ARRAY to avoid issues with std::size on member arrays, enable warnings for VLAs in C++.
-rw-r--r--scripts/genie.lua1
-rw-r--r--src/osd/modules/input/input_xinput.cpp9
-rw-r--r--src/osd/modules/render/d3d/d3dhlsl.cpp2
-rw-r--r--src/tools/chdman.cpp5
4 files changed, 8 insertions, 9 deletions
diff --git a/scripts/genie.lua b/scripts/genie.lua
index b6b9f303667..8bdcfdfdba2 100644
--- a/scripts/genie.lua
+++ b/scripts/genie.lua
@@ -1010,6 +1010,7 @@ end
-- warnings only applicable to C++ compiles
buildoptions_cpp {
"-Woverloaded-virtual",
+ "-Wvla",
}
if _OPTIONS["SANITIZE"] then
diff --git a/src/osd/modules/input/input_xinput.cpp b/src/osd/modules/input/input_xinput.cpp
index 5cdc3fd29a2..851a0799817 100644
--- a/src/osd/modules/input/input_xinput.cpp
+++ b/src/osd/modules/input/input_xinput.cpp
@@ -178,13 +178,13 @@ LSX 15 C
#if defined(OSD_WINDOWS) || defined(SDLMAME_WIN32)
+// emu
+#include "emu.h" // put this here before windows.h defines interface as a macro
+
#include "input_xinput.h"
#include "modules/lib/osdobj_common.h"
-// emu
-#include "emu.h"
-
// lib/util
#include "util/coretmpl.h"
@@ -196,9 +196,6 @@ LSX 15 C
#include <tuple>
#include <utility>
-// standard windows headers
-#include <windows.h>
-
#define XINPUT_LIBRARIES { "xinput1_4.dll", "xinput9_1_0.dll" }
diff --git a/src/osd/modules/render/d3d/d3dhlsl.cpp b/src/osd/modules/render/d3d/d3dhlsl.cpp
index a1e5f7d2e01..59a3762b4c2 100644
--- a/src/osd/modules/render/d3d/d3dhlsl.cpp
+++ b/src/osd/modules/render/d3d/d3dhlsl.cpp
@@ -571,7 +571,7 @@ void shaders::begin_frame(render_primitive_list *primlist)
std::fill(std::begin(target_to_screen), std::end(target_to_screen), 0);
std::fill(std::begin(targets_per_screen), std::end(targets_per_screen), 0);
- render_container *containers[sizeof(target_to_screen)/sizeof(*target_to_screen)];
+ EQUIVALENT_ARRAY(target_to_screen, render_container *) containers;
// Maximum potential runtime O(max_num_targets^2)
num_targets = 0;
diff --git a/src/tools/chdman.cpp b/src/tools/chdman.cpp
index 45438bc1f82..c414c05f5f5 100644
--- a/src/tools/chdman.cpp
+++ b/src/tools/chdman.cpp
@@ -13,6 +13,7 @@
#include "bitmap.h"
#include "cdrom.h"
#include "corefile.h"
+#include "coretmpl.h"
#include "hashing.h"
#include "md5.h"
#include "path.h"
@@ -517,8 +518,8 @@ public:
uint32_t samples = (uint64_t(m_info.rate) * uint64_t(effframe + 1) * uint64_t(1000000) + m_info.fps_times_1million - 1) / uint64_t(m_info.fps_times_1million) - first_sample;
// loop over channels and read the samples
- int channels = unsigned((std::min<std::size_t>)(m_info.channels, std::size(m_audio)));
- int16_t *samplesptr[sizeof(m_audio)/sizeof(*m_audio)];
+ int channels = unsigned(std::min<std::size_t>(m_info.channels, std::size(m_audio)));
+ EQUIVALENT_ARRAY(m_audio, int16_t *) samplesptr;
for (int chnum = 0; chnum < channels; chnum++)
{
// read the sound samples