Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Anton Khirnov <anton@khirnov.net>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH 2/2] Require compilers to support C17.
Date: Mon,  5 Feb 2024 20:54:40 +0100
Message-ID: <20240205195802.14522-2-anton@khirnov.net> (raw)
In-Reply-To: <20240205195802.14522-1-anton@khirnov.net>

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.
---
Now moving to C17 rather than C11, as the former contains important
fixes and its support across the compilers we care about should be
similar.

Now also tested with MSVC in wine, thanks to Martin for pointing me at
https://github.com/mstorsjo/msvc-wine
---
 configure          | 23 +++++++++++------------
 doc/developer.texi | 10 ++--------
 2 files changed, 13 insertions(+), 20 deletions(-)

diff --git a/configure b/configure
index f72533b7d2..1bb9e23f19 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=c17)             echo -Qstd=c17 ;;
             -flto*)               echo -ipo ;;
         esac
     done
@@ -4798,7 +4798,7 @@ suncc_flags(){
                     athlon*)                   echo -xarch=pentium_proa  ;;
                 esac
                 ;;
-            -std=c99)             echo -xc99              ;;
+            -std=c17)             echo -xc17              ;;
             -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 -xc17'
+        _ldflags='-std=c17'
         _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
+# some compilers silently accept -std=c17, 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
+test_cflags_cc -std=c17 ctype.h "__STDC_VERSION__ >= 201710L" &&
+    add_cflags -std=c17 || die "Compiler lacks C17 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=c17
 check_host_cflags -Wall
 check_host_cflags $host_cflags_speed
 
diff --git a/doc/developer.texi b/doc/developer.texi
index eed0ee4915..6e9807aa06 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 C17 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
-- 
2.42.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

  reply	other threads:[~2024-02-05 19:59 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-05 19:54 [FFmpeg-devel] [PATCH 1/2] lavc/refstruct: do not use max_align_t on MSVC Anton Khirnov
2024-02-05 19:54 ` Anton Khirnov [this message]
2024-02-05 20:12   ` [FFmpeg-devel] [PATCH 2/2] Require compilers to support C17 James Almer
2024-02-05 20:13     ` Anton Khirnov
2024-02-05 20:13   ` Devin Heitmueller
2024-02-05 20:30     ` Anton Khirnov
2024-02-05 20:33       ` James Almer
2024-02-05 20:40       ` Devin Heitmueller
2024-02-07  9:50         ` Anton Khirnov
2024-02-07 16:15           ` Devin Heitmueller
2024-02-07 16:36             ` Anton Khirnov
2024-02-05 20:53     ` Niklas Haas
2024-02-09 11:22       ` Dominik 'Rathann' Mierzejewski
2024-02-09 12:04         ` Kevin Wheatley
2024-02-05 20:20   ` Lynne
2024-02-05 20:27   ` Michael Niedermayer
2024-02-05 20:31     ` Anton Khirnov
2024-02-05 20:45       ` Michael Niedermayer
2024-02-07  9:55         ` Anton Khirnov
     [not found]           ` <2E73439B-3AE5-46FC-80FB-2D375FD852C5@cosmin.at>
2024-02-07 18:52             ` Cosmin Stejerean via ffmpeg-devel
2024-02-07 19:27               ` Lynne
     [not found]                 ` <1CBFE199-B1ED-47B5-BD97-7DA715EAB55B@cosmin.at>
2024-02-07 21:10                   ` Cosmin Stejerean via ffmpeg-devel
2024-02-07 21:19                     ` James Almer
2024-02-08  7:15                       ` Rémi Denis-Courmont
2024-02-08 10:42                         ` Andreas Rheinhardt
2024-02-07 21:48                     ` Lynne
     [not found]                       ` <8C790A7E-A236-4413-A4EB-AFE2F91E96A8@cosmin.at>
2024-02-08  0:36                         ` Cosmin Stejerean via ffmpeg-devel
2024-02-08  4:29                           ` Jean-Baptiste Kempf
2024-02-08 18:52                             ` Sean McGovern
2024-02-08 19:05                               ` James Almer
2024-02-08 19:46                                 ` Lynne
2024-02-05 20:55       ` Niklas Haas
2024-02-05 22:22         ` Stefano Sabatini
2024-02-07  9:53         ` Anton Khirnov
2024-02-06  6:50   ` Diederick C. Niehorster
2024-02-06 12:03     ` Lynne

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240205195802.14522-2-anton@khirnov.net \
    --to=anton@khirnov.net \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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 https://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/ https://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