You can't combine SDL_STRINGIFY_ARG() and SDL_FUNCTION
Build (All) / Create test plan (push) Has been cancelled
Build (All) / level1 (push) Has been cancelled
Build (All) / level2 (push) Has been cancelled

Removed obsolete documentation that shows this usage and macros that attempt it.

Also allow SDL_FUNCTION to be redefined by the application.

Fixes https://github.com/libsdl-org/SDL/issues/15004

(cherry picked from commit 6feb0e1333)
This commit is contained in:
Sam Lantinga
2026-02-08 11:56:12 -08:00
parent 576c2d2f2c
commit badd9e5a15
9 changed files with 97 additions and 127 deletions
+4 -2
View File
@@ -160,7 +160,7 @@ extern "C" {
#ifdef SDL_WIKI_DOCUMENTATION_SECTION
/**
* A macro that reports the current function being compiled.
* A constant that contains the current function being compiled.
*
* If SDL can't figure how the compiler reports this, it will use "???".
*
@@ -168,13 +168,15 @@ extern "C" {
*/
#define SDL_FUNCTION __FUNCTION__
#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 supports __func__ as a standard. */
#elif !defined(SDL_FUNCTION)
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 supports __func__ as a standard. */
# define SDL_FUNCTION __func__
#elif ((defined(__GNUC__) && (__GNUC__ >= 2)) || defined(_MSC_VER) || defined (__WATCOMC__))
# define SDL_FUNCTION __FUNCTION__
#else
# define SDL_FUNCTION "???"
#endif
#endif
#ifdef SDL_WIKI_DOCUMENTATION_SECTION
-6
View File
@@ -254,12 +254,6 @@ void *alloca(size_t);
/**
* Macro useful for building other macros with strings in them.
*
* For example:
*
* ```c
* #define LOG_ERROR(X) OutputDebugString(SDL_STRINGIFY_ARG(SDL_FUNCTION) ": " X "\n")`
* ```
*
* \param arg the text to turn into a string literal.
*
* \since This macro is available since SDL 3.2.0.
File diff suppressed because it is too large Load Diff
+3 -5
View File
@@ -28,8 +28,6 @@
#include "SDL_shaders_d3d11.h"
#define SDL_COMPOSE_ERROR(str) SDL_STRINGIFY_ARG(SDL_FUNCTION) ", " str
#if SDL_WINAPI_FAMILY_PHONE
#error Need to build shaders with level_9_3
#endif
@@ -82,7 +80,7 @@ bool D3D11_CreateVertexShader(ID3D11Device1 *d3dDevice, ID3D11VertexShader **ver
NULL,
vertexShader);
if (FAILED(result)) {
return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateVertexShader"), result);
return WIN_SetErrorFromHRESULT("ID3D11Device1::CreateVertexShader", result);
}
// Create an input layout for SDL's vertex shader:
@@ -93,7 +91,7 @@ bool D3D11_CreateVertexShader(ID3D11Device1 *d3dDevice, ID3D11VertexShader **ver
sizeof(D3D11_VertexShader),
inputLayout);
if (FAILED(result)) {
return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateInputLayout"), result);
return WIN_SetErrorFromHRESULT("ID3D11Device1::CreateInputLayout", result);
}
return true;
}
@@ -108,7 +106,7 @@ bool D3D11_CreatePixelShader(ID3D11Device1 *d3dDevice, D3D11_Shader shader, ID3D
NULL,
pixelShader);
if (FAILED(result)) {
return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreatePixelShader"), result);
return WIN_SetErrorFromHRESULT("ID3D11Device1::CreatePixelShader", result);
}
return true;
}
File diff suppressed because it is too large Load Diff
@@ -25,12 +25,6 @@
#include "../../core/windows/SDL_windows.h"
#include <XGameRuntime.h>
#if defined(_MSC_VER) && !defined(__clang__)
#define SDL_COMPOSE_ERROR(str) SDL_FUNCTION ", " str
#else
#define SDL_COMPOSE_ERROR(str) SDL_STRINGIFY_ARG(SDL_FUNCTION) ", " str
#endif
static const GUID SDL_IID_ID3D12Device1 = { 0x77acce80, 0x638e, 0x4e65, { 0x88, 0x95, 0xc1, 0xf2, 0x33, 0x86, 0x86, 0x3e } };
static const GUID SDL_IID_ID3D12Resource = { 0x696442be, 0xa72e, 0x4059, { 0xbc, 0x79, 0x5b, 0x5c, 0x98, 0x04, 0x0f, 0xad } };
static const GUID SDL_IID_IDXGIDevice1 = { 0x77db970f, 0x6276, 0x48ba, { 0xba, 0x28, 0x07, 0x01, 0x43, 0xb4, 0x39, 0x2c } };
@@ -53,38 +47,38 @@ HRESULT D3D12_XBOX_CreateDevice(ID3D12Device **device, bool createDebug)
result = D3D12XboxCreateDevice(NULL, &params, SDL_IID_ID3D12Device1, (void **) device);
if (FAILED(result)) {
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("[xbox] D3D12XboxCreateDevice"), result);
WIN_SetErrorFromHRESULT("D3D12XboxCreateDevice", result);
goto done;
}
result = (*device)->QueryInterface(SDL_IID_IDXGIDevice1, (void **) &dxgiDevice);
if (FAILED(result)) {
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("[xbox] ID3D12Device to IDXGIDevice1"), result);
WIN_SetErrorFromHRESULT("ID3D12Device to IDXGIDevice1", result);
goto done;
}
result = dxgiDevice->GetAdapter(&dxgiAdapter);
if (FAILED(result)) {
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("[xbox] dxgiDevice->GetAdapter"), result);
WIN_SetErrorFromHRESULT("dxgiDevice->GetAdapter", result);
goto done;
}
result = dxgiAdapter->EnumOutputs(0, &dxgiOutput);
if (FAILED(result)) {
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("[xbox] dxgiAdapter->EnumOutputs"), result);
WIN_SetErrorFromHRESULT("dxgiAdapter->EnumOutputs", result);
goto done;
}
// Set frame interval
result = (*device)->SetFrameIntervalX(dxgiOutput, D3D12XBOX_FRAME_INTERVAL_60_HZ, 1, D3D12XBOX_FRAME_INTERVAL_FLAG_NONE);
if (FAILED(result)) {
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("[xbox] SetFrameIntervalX"), result);
WIN_SetErrorFromHRESULT("SetFrameIntervalX", result);
goto done;
}
result = (*device)->ScheduleFrameEventX(D3D12XBOX_FRAME_EVENT_ORIGIN, 0, NULL, D3D12XBOX_SCHEDULE_FRAME_EVENT_FLAG_NONE);
if (FAILED(result)) {
WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("[xbox] ScheduleFrameEventX"), result);
WIN_SetErrorFromHRESULT("ScheduleFrameEventX", result);
goto done;
}
@@ -27,8 +27,6 @@
#include "SDL_shaders_d3d12.h"
#define SDL_COMPOSE_ERROR(str) SDL_STRINGIFY_ARG(SDL_FUNCTION) ", " str
// The shaders here were compiled with compile_shaders.bat
#define g_main D3D12_PixelShader_Colors
@@ -29,8 +29,6 @@
#include "SDL_shaders_d3d12.h"
#define SDL_COMPOSE_ERROR(str) SDL_STRINGIFY_ARG(SDL_FUNCTION) ", " str
// Shader blob headers are generated with a pre-build step using compile_shaders_xbox.bat
#define g_main D3D12_PixelShader_Colors
@@ -29,8 +29,6 @@
#include "SDL_shaders_d3d12.h"
#define SDL_COMPOSE_ERROR(str) SDL_STRINGIFY_ARG(SDL_FUNCTION) ", " str
// Shader blob headers are generated with a pre-build step using compile_shaders_xbox.bat