Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH] avutil/attributes: don't force format checking to __gnu_printf__ on mingw build (PR #20643)
@ 2025-10-04  6:54 Kacper Michajłow via ffmpeg-devel
  0 siblings, 0 replies; only message in thread
From: Kacper Michajłow via ffmpeg-devel @ 2025-10-04  6:54 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Kacper Michajłow

PR #20643 opened by Kacper Michajłow (kasper93)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20643
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20643.patch

Use __MINGW_{PRINTF,SCANF}_FORMAT which matches the format check for
implementation that is actually used.


From e6d5af7078a1a887abd69a5fd28d47baa82238f0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= <kasper93@gmail.com>
Date: Sat, 4 Oct 2025 08:49:21 +0200
Subject: [PATCH] avutil/attributes: don't force format checking to
 __gnu_printf__ on mingw build
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Use __MINGW_{PRINTF,SCANF}_FORMAT which matches the format check for
implementation that is actually used.

Signed-off-by: Kacper Michajłow <kasper93@gmail.com>
---
 configure              |  4 ----
 libavutil/attributes.h | 24 ++++++++++++++++++++++--
 2 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/configure b/configure
index 3de3b150ef..7828381b5d 100755
--- a/configure
+++ b/configure
@@ -6225,8 +6225,6 @@ probe_libc(){
         if ! test_${pfx}cpp_condition crtdefs.h "defined(_UCRT)"; then
             add_${pfx}cppflags -D__USE_MINGW_ANSI_STDIO=1
         fi
-        eval test \$${pfx_no_}cc_type = "gcc" &&
-            add_${pfx}cppflags -D__printf__=__gnu_printf__
         test_${pfx}cpp_condition windows.h "!defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0600" &&
             add_${pfx}cppflags -D_WIN32_WINNT=0x0600
         add_${pfx}cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
@@ -6244,8 +6242,6 @@ probe_libc(){
             add_${pfx}cppflags -D__MSVCRT_VERSION__=0x0700
         test_${pfx}cpp_condition windows.h "!defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0600" &&
             add_${pfx}cppflags -D_WIN32_WINNT=0x0600
-        eval test \$${pfx_no_}cc_type = "gcc" &&
-            add_${pfx}cppflags -D__printf__=__gnu_printf__
         add_${pfx}cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600
     elif test_${pfx}cpp_condition crtversion.h "defined _VC_CRT_MAJOR_VERSION"; then
         eval ${pfx}libc_type=msvcrt
diff --git a/libavutil/attributes.h b/libavutil/attributes.h
index 772e327fa4..4f05ce7f40 100644
--- a/libavutil/attributes.h
+++ b/libavutil/attributes.h
@@ -172,11 +172,31 @@
 
 #if defined(__GNUC__) || defined(__clang__)
 #    define av_builtin_constant_p __builtin_constant_p
-#    define av_printf_format(fmtpos, attrpos) __attribute__((__format__(__printf__, fmtpos, attrpos)))
-#    define av_scanf_format(fmtpos, attrpos) __attribute__((__format__(__scanf__, fmtpos, attrpos)))
 #else
 #    define av_builtin_constant_p(x) 0
+#endif
+
+#ifdef __MINGW_PRINTF_FORMAT
+#    define AV_PRINTF_FMT __MINGW_PRINTF_FORMAT
+#elif defined(__has_attribute) && __has_attribute(format)
+#    define AV_PRINTF_FMT __printf__
+#endif
+
+#ifdef __MINGW_SCANF_FORMAT
+#    define AV_SCANF_FMT __MINGW_SCANF_FORMAT
+#elif defined(__has_attribute) && __has_attribute(format)
+#    define AV_SCANF_FMT __scanf__
+#endif
+
+#ifdef AV_PRINTF_FMT
+#    define av_printf_format(fmtpos, attrpos) __attribute__((format(AV_PRINTF_FMT, fmtpos, attrpos)))
+#else
 #    define av_printf_format(fmtpos, attrpos)
+#endif
+
+#ifdef AV_SCANF_FMT
+#    define av_scanf_format(fmtpos, attrpos) __attribute__((format(AV_SCANF_FMT, fmtpos, attrpos)))
+#else
 #    define av_scanf_format(fmtpos, attrpos)
 #endif
 
-- 
2.49.1

_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-10-04  6:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-04  6:54 [FFmpeg-devel] [PATCH] avutil/attributes: don't force format checking to __gnu_printf__ on mingw build (PR #20643) Kacper Michajłow via ffmpeg-devel

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ http://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git