Commit 09c9d50cb6 for ffmpeg
commit 09c9d50cb690bda3392286077cad8c936c731d25
Author: Clément Péron <peron.clem@gmail.com>
Date: Sat Nov 28 17:19:57 2026 +0100
avutil/common: check for UINT64_C after including stdint.h
The check for __STDC_CONSTANT_MACROS is done before stdint.h is
included, so it can only see UINT64_C when the caller included stdint.h
first. A C++ build that includes common.h first stops with an error,
even when the C library defines the macro without
__STDC_CONSTANT_MACROS, as glibc does since 2.18 and as C++11 requires.
Do the check after the includes and test UINT64_C alone. The error is
now raised only when the macro is really missing.
Based on a patch by Calvin Walton <calvin.walton@kepstin.ca>.
Signed-off-by: Clément Péron <peron.clem@gmail.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
diff --git a/libavutil/common.h b/libavutil/common.h
index cba78c5fd8..dfd8787be5 100644
--- a/libavutil/common.h
+++ b/libavutil/common.h
@@ -26,10 +26,6 @@
#ifndef AVUTIL_COMMON_H
#define AVUTIL_COMMON_H
-#if defined(__cplusplus) && !defined(__STDC_CONSTANT_MACROS) && !defined(UINT64_C)
-#error missing -D__STDC_CONSTANT_MACROS / #define __STDC_CONSTANT_MACROS
-#endif
-
#include <errno.h>
#include <inttypes.h>
#include <limits.h>
@@ -39,6 +35,10 @@
#include <stdlib.h>
#include <string.h>
+#if defined(__cplusplus) && !defined(UINT64_C)
+#error missing -D__STDC_CONSTANT_MACROS / #define __STDC_CONSTANT_MACROS
+#endif
+
#include "attributes.h"
#include "error.h"
#include "macros.h"