From c959f9f0d831ec2620091e037a48768164cb5535 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Fri, 24 Oct 2025 10:01:01 -0700
Subject: [PATCH] Define SDL_FILE as __FILE_NAME__, if available
---
include/SDL3/SDL_assert.h | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/include/SDL3/SDL_assert.h b/include/SDL3/SDL_assert.h
index 9644ce88ae9c1..ddb89b8848f85 100644
--- a/include/SDL3/SDL_assert.h
+++ b/include/SDL3/SDL_assert.h
@@ -176,7 +176,7 @@ extern "C" {
# define SDL_FUNCTION "???"
#endif
-#ifndef SDL_FILE
+#ifdef SDL_WIKI_DOCUMENTATION_SECTION
/**
* A macro that reports the current file being compiled.
@@ -184,16 +184,21 @@ extern "C" {
* This macro is only defined if it isn't already defined, so to override it
* (perhaps with something that doesn't provide path information at all, so
* build machine information doesn't leak into public binaries), apps can
- * define this macro before including SDL_assert.h. For example, Clang and GCC
- * can define this to `FILE_NAME` to get just the source filename instead of
- * the full path.
+ * define this macro before including SDL.h or SDL_assert.h.
*
* \since This macro is available since SDL 3.2.0.
*/
+#define SDL_FILE __FILE_NAME__
+
+#elif !defined(SDL_FILE)
+#ifdef __FILE_NAME__
+#define SDL_FILE __FILE_NAME__
+#else
#define SDL_FILE __FILE__
#endif
+#endif
-#ifndef SDL_ASSERT_FILE
+#ifdef SDL_WIKI_DOCUMENTATION_SECTION
/**
* A macro that reports the current file being compiled, for use in
@@ -208,6 +213,9 @@ extern "C" {
* \since This macro is available since SDL 3.4.0.
*/
#define SDL_ASSERT_FILE SDL_FILE
+
+#elif !defined(SDL_ASSERT_FILE)
+#define SDL_ASSERT_FILE SDL_FILE
#endif