Use EQUIVALENT_ARRAY to avoid issues with std::size on member arrays, enable warnings for VLAs in C++.

This commit is contained in:
Vas Crabb 2023-02-01 16:12:58 +11:00
parent c4830168a5
commit 0ae68e4dea
4 changed files with 8 additions and 9 deletions

View File

@ -1010,6 +1010,7 @@ end
-- warnings only applicable to C++ compiles
buildoptions_cpp {
"-Woverloaded-virtual",
"-Wvla",
}
if _OPTIONS["SANITIZE"] then

View File

@ -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" }

View File

@ -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;

View File

@ -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