From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 4867E48556 for ; Mon, 5 Feb 2024 19:59:00 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id EDAF468D13E; Mon, 5 Feb 2024 21:58:59 +0200 (EET) Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4D01D68D09E for ; Mon, 5 Feb 2024 21:58:53 +0200 (EET) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=AIOnviID; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id DA8D4447A for ; Mon, 5 Feb 2024 20:58:52 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id z5Zi9HXsoE1H for ; Mon, 5 Feb 2024 20:58:52 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1707163131; bh=xVYjRas7evux0Ice+cRYbrUwsKngq0S243Pn+tKr04Q=; h=From:To:Subject:Date:In-Reply-To:References:From; b=AIOnviIDdLGq8p1jj2NloN6YUK9JKBzIi1tk7hcffUm7MVSHHC4wccYjYZpDYV3cq BcM6xBTPXBRYGS6sOvT/Q95P6oHLk4KYDVgjbFBA3OGhC18VNdkFcZCWKoFjk4Fsib OZ/0VAzwV5R2GJ3IxGhB7fuXkLd3N4H1maRmvGwctya6upr0PPxgrtkSF9fkoN7m26 QVBb41BLwAKjAfDThl6Ckw2AVpiUBr8T3bQlJHYmePoQEHKxRxBJWQWTWtmCebOtFt beMpATtIylza1hGsmMLXirqClLKeWQT5JOXSSPFmbg/kkObuKMel15grzYlQJgz3AM msqSgHOjjC2lg== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id DB07158B for ; Mon, 5 Feb 2024 20:58:51 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id C31803A076E for ; Mon, 5 Feb 2024 20:58:51 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 5 Feb 2024 20:54:40 +0100 Message-ID: <20240205195802.14522-2-anton@khirnov.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240205195802.14522-1-anton@khirnov.net> References: <20240205195802.14522-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/2] Require compilers to support C17. X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: 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".