diff mbox series

[FFmpeg-devel,v3] Require compilers to support C11.

Message ID 20240209165459.26190-1-anton@khirnov.net
State Accepted
Commit 75697836b1db3e0f0a3b7061be6be28d00c675a0
Headers show
Series [FFmpeg-devel,v3] Require compilers to support C11. | expand

Checks

Context Check Description
yinshiyou/commit_msg_loongarch64 warning The first line of the commit message must start with a context terminated by a colon and a space, for example "lavu/opt: " or "doc: ".
andriy/commit_msg_x86 warning The first line of the commit message must start with a context terminated by a colon and a space, for example "lavu/opt: " or "doc: ".
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Anton Khirnov Feb. 9, 2024, 4:54 p.m. UTC
It should be available in all relevant modern compilers and will allow
us to use features like anonymous unions.

Note that stdatomic.h is still emulated on MSVC, as current versions
require the /experimental:c11atomics, and do not support
ATOMIC_VAR_INIT() anyway.
---
The general consensus seems to be C11 now, and C17 later, for various
values of later.
---
 Changelog          |  3 +++
 configure          | 19 +++++++++----------
 doc/developer.texi | 10 ++--------
 3 files changed, 14 insertions(+), 18 deletions(-)

Comments

Anton Khirnov Feb. 12, 2024, 11:04 a.m. UTC | #1
Any more comments on this?

Anyone opposed to this going to master this week?
James Almer Feb. 12, 2024, 11:52 a.m. UTC | #2
On 2/12/2024 8:04 AM, Anton Khirnov wrote:
> Any more comments on this?
> 
> Anyone opposed to this going to master this week?

Michael said his machines needed updating gcc for c17. Wait to see if 
that still applies to c11.
Michael Niedermayer Feb. 13, 2024, 2:38 a.m. UTC | #3
On Mon, Feb 12, 2024 at 08:52:14AM -0300, James Almer wrote:
> On 2/12/2024 8:04 AM, Anton Khirnov wrote:
> > Any more comments on this?
> > 
> > Anyone opposed to this going to master this week?
> 
> Michael said his machines needed updating gcc for c17. Wait to see if that
> still applies to c11.

I didnt see a problem with C11 when i tested it last time but i didnt
test all cross build environments i have, ill do that now/soon

thanks alot for asking though!

[...]
diff mbox series

Patch

diff --git a/Changelog b/Changelog
index c5fb21d198..610ee61dd6 100644
--- a/Changelog
+++ b/Changelog
@@ -24,6 +24,9 @@  version <next>:
 - ffmpeg CLI options may now be used as -/opt <path>, which is equivalent
   to -opt <contents of file <path>>
 - showinfo bitstream filter
+- a C11-compliant compiler is now required; note that this requirement
+  will be bumped to C17 in the near future, so consider updating your
+  build environment if it lacks C17 support
 
 version 6.1:
 - libaribcaption decoder
diff --git a/configure b/configure
index f72533b7d2..d66694e83e 100755
--- a/configure
+++ b/configure
@@ -4705,7 +4705,7 @@  msvc_common_flags(){
             # generic catch all at the bottom will print the original flag.
             -Wall)                ;;
             -Wextra)              ;;
-            -std=c*)              ;;
+            -std=c*)              echo /std:${flag#-std=};;
             # Common flags
             -fomit-frame-pointer) ;;
             -g)                   echo -Z7 ;;
@@ -4750,7 +4750,7 @@  icl_flags(){
             # Despite what Intel's documentation says -Wall, which is supported
             # on Windows, does enable remarks so disable them here.
             -Wall)                echo $flag -Qdiag-disable:remark ;;
-            -std=c99)             echo -Qstd=c99 ;;
+            -std=c11)             echo -Qstd=c11 ;;
             -flto*)               echo -ipo ;;
         esac
     done
@@ -4798,7 +4798,7 @@  suncc_flags(){
                     athlon*)                   echo -xarch=pentium_proa  ;;
                 esac
                 ;;
-            -std=c99)             echo -xc99              ;;
+            -std=c11)             echo -xc11              ;;
             -fomit-frame-pointer) echo -xregs=frameptr    ;;
             -fPIC)                echo -KPIC -xcode=pic32 ;;
             -W*,*)                echo $flag              ;;
@@ -4887,8 +4887,8 @@  probe_cc(){
         _type=suncc
         _ident=$($_cc -V 2>&1 | head -n1 | cut -d' ' -f 2-)
         _DEPCMD='$(DEP$(1)) $(DEP$(1)FLAGS) $($(1)DEP_FLAGS) $< | sed -e "1s,^.*: ,$@: ," -e "\$$!s,\$$, \\\," -e "1!s,^.*: , ," > $(@:.o=.d)'
-        _DEPFLAGS='-xM1 -xc99'
-        _ldflags='-std=c99'
+        _DEPFLAGS='-xM1 -xc11'
+        _ldflags='-std=c11'
         _cflags_speed='-O5'
         _cflags_size='-O5 -xspace'
         _flags_filter=suncc_flags
@@ -5517,21 +5517,20 @@  if test "$?" != 0; then
     die "C compiler test failed."
 fi
 
-add_cppflags -D_ISOC99_SOURCE
+add_cppflags -D_ISOC11_SOURCE
 add_cxxflags -D__STDC_CONSTANT_MACROS
 check_cxxflags -std=c++11 || check_cxxflags -std=c++0x
 
 # some compilers silently accept -std=c11, so we also need to check that the
 # version macro is defined properly
 test_cflags_cc -std=c11 ctype.h "__STDC_VERSION__ >= 201112L" &&
-    add_cflags -std=c11 ||
-    check_cflags -std=c99
+    add_cflags -std=c11 || die "Compiler lacks C11 support"
 
 check_cppflags -D_FILE_OFFSET_BITS=64
 check_cppflags -D_LARGEFILE_SOURCE
 
-add_host_cppflags -D_ISOC99_SOURCE
-check_host_cflags -std=c99
+add_host_cppflags -D_ISOC11_SOURCE
+check_host_cflags -std=c11
 check_host_cflags -Wall
 check_host_cflags $host_cflags_speed
 
diff --git a/doc/developer.texi b/doc/developer.texi
index eed0ee4915..c86bb5820c 100644
--- a/doc/developer.texi
+++ b/doc/developer.texi
@@ -56,14 +56,8 @@  and should try to fix issues their commit causes.
 
 @section Language
 
-FFmpeg is mainly programmed in the ISO C99 language, extended with:
-@itemize @bullet
-@item
-Atomic operations from C11 @file{stdatomic.h}. They are emulated on
-architectures/compilers that do not support them, so all FFmpeg-internal code
-may use atomics without any extra checks. However, @file{stdatomic.h} must not
-be included in public headers, so they stay C99-compatible.
-@end itemize
+FFmpeg is mainly programmed in the ISO C11 language, except for the public
+headers which must stay C99 compatible.
 
 Compiler-specific extensions may be used with good reason, but must not be
 depended on, i.e. the code must still compile and work with compilers lacking