aboutsummaryrefslogtreecommitdiffstats
path: root/libavutil/avutil.h
diff options
context:
space:
mode:
authorZhao Zhili <zhilizhao@tencent.com>2023-09-19 00:52:21 +0800
committerZhao Zhili <zhilizhao@tencent.com>2023-09-19 00:52:21 +0800
commitba9cd06c763648ecd1f447d7a672a0da85749d30 (patch)
tree54cf82437066bdbf85681043cb2551f85ab6e176 /libavutil/avutil.h
parent1c61aa1a02d66c2abf8365aae558fd5782c7a594 (diff)
downloadffmpeg-ba9cd06c763648ecd1f447d7a672a0da85749d30.tar.gz
avutil/avutil: make AV_TIME_BASE_Q available in C++
ISO C++ forbids compound-literals. It's not available with MSVC. This is a known issue from 10 years ago, and that's why there is a av_get_time_base_q(). Since we have no plan to remove AV_TIME_BASE_Q, just make it available in C++. There are multiple choices: 1. Use C++11 syntax: AVRational{1, AV_TIME_BASE} Users may still use C++98 to write new code. So no. 2. Use av_get_time_base_q(). It's for this purpose. But it's not compile time constants as AV_TIME_BASE_Q in C. So I choose av_make_q() as Anton's suggestion. https://libav-devel.libav.narkive.com/ZQCWfTun/patch-0-2-fix-avutil-h-usage-from-c Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
Diffstat (limited to 'libavutil/avutil.h')
-rw-r--r--libavutil/avutil.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/libavutil/avutil.h b/libavutil/avutil.h
index 30bec192f1..a362c8baa8 100644
--- a/libavutil/avutil.h
+++ b/libavutil/avutil.h
@@ -257,7 +257,12 @@ const char *av_get_media_type_string(enum AVMediaType media_type);
* Internal time base represented as fractional value
*/
+#ifdef __cplusplus
+/* ISO C++ forbids compound-literals. */
+#define AV_TIME_BASE_Q av_make_q(1, AV_TIME_BASE)
+#else
#define AV_TIME_BASE_Q (AVRational){1, AV_TIME_BASE}
+#endif
/**
* @}