From faeb2b1f22571a55c5c869fcec1229002adb6906 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Wed, 7 Feb 2024 13:16:35 -0800
Subject: [PATCH] Fixed warning C4204: nonstandard extension used: non-constant
aggregate initializer when built with Visual Studio 2019
---
src/audio/wasapi/SDL_wasapi.c | 4 +++-
.../windows/hidapi_descriptor_reconstruct.c | 9 ++++-----
src/render/direct3d11/SDL_render_d3d11.c | 18 +++++++++---------
src/render/direct3d12/SDL_render_d3d12.c | 18 +++++++++---------
src/video/windows/SDL_windowsevents.c | 10 +++++-----
src/video/windows/SDL_windowswindow.c | 6 +++++-
6 files changed, 35 insertions(+), 30 deletions(-)
diff --git a/src/audio/wasapi/SDL_wasapi.c b/src/audio/wasapi/SDL_wasapi.c
index 78cf3f4c85fb..e2a73438affc 100644
--- a/src/audio/wasapi/SDL_wasapi.c
+++ b/src/audio/wasapi/SDL_wasapi.c
@@ -265,7 +265,9 @@ static void WASAPI_DetectDevices(SDL_AudioDevice **default_output, SDL_AudioDevi
{
int rc;
// this blocks because it needs to finish before the audio subsystem inits
- mgmtthrtask_DetectDevicesData data = { default_output, default_capture };
+ mgmtthrtask_DetectDevicesData data;
+ data.default_output = default_output;
+ data.default_capture = default_capture;
WASAPI_ProxyToManagementThread(mgmtthrtask_DetectDevices, &data, &rc);
}
diff --git a/src/hidapi/windows/hidapi_descriptor_reconstruct.c b/src/hidapi/windows/hidapi_descriptor_reconstruct.c
index f6e693f69151..6697d3c3c3a8 100644
--- a/src/hidapi/windows/hidapi_descriptor_reconstruct.c
+++ b/src/hidapi/windows/hidapi_descriptor_reconstruct.c
@@ -187,11 +187,10 @@ int hid_winapi_descriptor_reconstruct_pp_data(void *preparsed_data, unsigned cha
return -1;
}
- struct rd_buffer rpt_desc = {
- .buf = buf,
- .buf_size = buf_size,
- .byte_idx = 0
- };
+ struct rd_buffer rpt_desc;
+ rpt_desc.buf = buf;
+ rpt_desc.buf_size = buf_size;
+ rpt_desc.byte_idx = 0;
// Set pointer to the first node of link_collection_nodes
phid_pp_link_collection_node link_collection_nodes = (phid_pp_link_collection_node)(((unsigned char*)&pp_data->caps[0]) + pp_data->FirstByteOfLinkCollectionArray);
diff --git a/src/render/direct3d11/SDL_render_d3d11.c b/src/render/direct3d11/SDL_render_d3d11.c
index 05b6e1979ba7..3b603408e22d 100644
--- a/src/render/direct3d11/SDL_render_d3d11.c
+++ b/src/render/direct3d11/SDL_render_d3d11.c
@@ -2349,20 +2349,20 @@ static int D3D11_SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *c
}
#if SDL_HAVE_YUV
if (textureData->yuv) {
- ID3D11ShaderResourceView *shaderResources[] = {
- textureData->mainTextureResourceView,
- textureData->mainTextureResourceViewU,
- textureData->mainTextureResourceViewV
- };
+ ID3D11ShaderResourceView *shaderResources[3];
+
+ shaderResources[0] = textureData->mainTextureResourceView;
+ shaderResources[1] = textureData->mainTextureResourceViewU;
+ shaderResources[2] = textureData->mainTextureResourceViewV;
return D3D11_SetDrawState(renderer, cmd, textureData->shader, textureData->shader_params,
SDL_arraysize(shaderResources), shaderResources, textureSampler, matrix);
} else if (textureData->nv12) {
- ID3D11ShaderResourceView *shaderResources[] = {
- textureData->mainTextureResourceView,
- textureData->mainTextureResourceViewNV,
- };
+ ID3D11ShaderResourceView *shaderResources[2];
+
+ shaderResources[0] = textureData->mainTextureResourceView;
+ shaderResources[1] = textureData->mainTextureResourceViewNV;
return D3D11_SetDrawState(renderer, cmd, textureData->shader, textureData->shader_params,
SDL_arraysize(shaderResources), shaderResources, textureSampler, matrix);
diff --git a/src/render/direct3d12/SDL_render_d3d12.c b/src/render/direct3d12/SDL_render_d3d12.c
index 31959df39da2..9c13499ee276 100644
--- a/src/render/direct3d12/SDL_render_d3d12.c
+++ b/src/render/direct3d12/SDL_render_d3d12.c
@@ -2701,11 +2701,11 @@ static int D3D12_SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *c
}
#if SDL_HAVE_YUV
if (textureData->yuv) {
- D3D12_CPU_DESCRIPTOR_HANDLE shaderResources[] = {
- textureData->mainTextureResourceView,
- textureData->mainTextureResourceViewU,
- textureData->mainTextureResourceViewV
- };
+ D3D12_CPU_DESCRIPTOR_HANDLE shaderResources[3];
+
+ shaderResources[0] = textureData->mainTextureResourceView;
+ shaderResources[1] = textureData->mainTextureResourceViewU;
+ shaderResources[2] = textureData->mainTextureResourceViewV;
/* Make sure each texture is in the correct state to be accessed by the pixel shader. */
D3D12_TransitionResource(rendererData, textureData->mainTexture, textureData->mainResourceState, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
@@ -2717,10 +2717,10 @@ static int D3D12_SetCopyState(SDL_Renderer *renderer, const SDL_RenderCommand *c
return D3D12_SetDrawState(renderer, cmd, textureData->shader, textureData->shader_params, D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE, SDL_arraysize(shaderResources), shaderResources, textureSampler, matrix);
} else if (textureData->nv12) {
- D3D12_CPU_DESCRIPTOR_HANDLE shaderResources[] = {
- textureData->mainTextureResourceView,
- textureData->mainTextureResourceViewNV,
- };
+ D3D12_CPU_DESCRIPTOR_HANDLE shaderResources[2];
+
+ shaderResources[0] = textureData->mainTextureResourceView;
+ shaderResources[1] = textureData->mainTextureResourceViewNV;
/* Make sure each texture is in the correct state to be accessed by the pixel shader. */
D3D12_TransitionResource(rendererData, textureData->mainTexture, textureData->mainResourceState, D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE);
diff --git a/src/video/windows/SDL_windowsevents.c b/src/video/windows/SDL_windowsevents.c
index 0c14786bf8b1..33e8a30e62bf 100644
--- a/src/video/windows/SDL_windowsevents.c
+++ b/src/video/windows/SDL_windowsevents.c
@@ -966,11 +966,11 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
if (IS_HIGH_SURROGATE(wParam)) {
data->high_surrogate = (WCHAR)wParam;
} else {
- WCHAR utf16[] = {
- data->high_surrogate ? data->high_surrogate : (WCHAR)wParam,
- data->high_surrogate ? (WCHAR)wParam : L'\0',
- L'\0'
- };
+ WCHAR utf16[3];
+
+ utf16[0] = data->high_surrogate ? data->high_surrogate : (WCHAR)wParam;
+ utf16[1] = data->high_surrogate ? (WCHAR)wParam : L'\0';
+ utf16[2] = L'\0';
char utf8[5];
int result = WIN_WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, utf16, -1, utf8, sizeof(utf8), NULL, NULL);
diff --git a/src/video/windows/SDL_windowswindow.c b/src/video/windows/SDL_windowswindow.c
index f530d00e70c4..d3a03053e5f1 100644
--- a/src/video/windows/SDL_windowswindow.c
+++ b/src/video/windows/SDL_windowswindow.c
@@ -719,7 +719,11 @@ int WIN_CreateWindow(SDL_VideoDevice *_this, SDL_Window *window, SDL_PropertiesI
We can use (-1, -1, 0, 0) boundary to make sure no pixels are being blurred
*/
HRGN rgn = CreateRectRgn(-1, -1, 0, 0);
- DWM_BLURBEHIND bb = {DWM_BB_ENABLE | DWM_BB_BLURREGION, TRUE, rgn, FALSE};
+ DWM_BLURBEHIND bb;
+ bb.flags = (DWM_BB_ENABLE | DWM_BB_BLURREGION);
+ bb.enable = TRUE;
+ bb.blur_region = rgn;
+ bb.transition_on_maxed = FALSE;
DwmEnableBlurBehindWindowFunc(hwnd, &bb);
DeleteObject(rgn);
}