From patchwork Fri Feb 9 16:54:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 46139 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:a586:b0:19e:8a94:b663 with SMTP id gd6csp1061110pzc; Fri, 9 Feb 2024 08:56:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IHbpzM/0jg5uCFwkARWIQtdbrbshkGXAedYUi2pr31aaEPa4IsVRb2hwQG7LhY2nsuQemNb X-Received: by 2002:aa7:df82:0:b0:560:658:a263 with SMTP id b2-20020aa7df82000000b005600658a263mr1811659edy.19.1707497807624; Fri, 09 Feb 2024 08:56:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707497807; cv=none; d=google.com; s=arc-20160816; b=gvSFjJeZcGHBR9SK475SVXueo1Vi/57DhBLR47L3nFLKyeJXObbY5u5NYAPcICuBem epIOnr+bNuHjReembV5LWIqRqyeMLqQt+aUJ6V431XvD6Y0yAef8u5ockmKvJMMRn8ci DTl8KTSj/HPPzF/Lx3WU8d4XFJlRWeej1Jp/cFvlQtd1CiYlltH5vbbwvObz4e+wSwP6 MsQ7wx9VZQCXwI3j7XbeRAYWI/10Uc8mFUZmvi02pBx3xbfpJ/s5Td92NuFtlP+U5qzd 5006meLoN/Ap4/S7YBx+Zw6h7TXCdCdC+6PG9YUeVzxpUEf/aq+fLXntjbnBBOyrUlrx sfnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=BlME8dWgC1YxereIhHZ0U0iSvWN/OcofcKCN9jYRymg=; fh=LSHXArasmfJLoex7q/Sja6lNS/PdMc8E8+mCtxquD9A=; b=gTv1v1fo28FN4Ssv4XDxMo1I0OJZ1idc6mu0L1rkhytRj+DFX7IMmJUnQVEHtlzAmH NVfFTP9p2ie1Pd7eYdC4FFVf+8i6Z/DFAHDHfq8i+ueRTbZd7nr2xzy6u9WL88esBsJc hlsVdWkJJosFrNKAr/x4lsi60CZozKfnX6giSs+qhZNogLcEpSw2Db5HHyHMCsRx+Btu H6FgrId+axq6uMeOZHY/xxglcF0ynL0YxX4s0Ad3qgn+5J3Pcae7ZSsZcg0UiwB7obna FGzLRRO0SntrNYTCP5W6+090q3lMDLGl+cOmJ6yNQbPoiAw0JsN5umtNDkFny/XIh2oy DjYw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=bijZpXZS; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org X-Forwarded-Encrypted: i=1; AJvYcCWG3RgDIUuNJ57/8gmhlilAy8y4Y03fjR/9YhToECTqvExDrfTIKWIVxrTCKPSfCPgFek+BJupfc18ZMvYrRgQDfcRNSAT1jG4C/atWOvVbL4813lLePBYP3cfxZakrzSz6jj5iIr9bSnX6m6X1sCpGeLOrYv1nw9WdCxl9l/Oo9ll+BzfZ6inXCBwtqxpAgQ9u4kss0aBYJvn0KYZKwOmFC8LiLAPXiabUg0nCoSRdoMlfkX2dJ0ZeOd+OE05PmZyFJWjsY/wRxC7xA+Mpke888l5cmzfRUZPV8edS2T2nVW69os7xK/LtKJwYy8QLaShjwUMwRgtExpfHLjgy6Yhdl1l0qu5bf7TB2GTTvsP2Vjo6LaSIOxGyTvRod0Hj7Re0I9XYQ9u2X/R9gZBlkzmmaY5zEcnX0ROF0pvasM9lqLNsq/EXN8UhYrTT9cLG4p228dOyIcn8ENBSjEUTrLYuW/HQwtsJfbezNxzPvfkZ518d6HnFU3Tgis22Ga0JU7A2W5IwGMFtHWWOhM5YZTpylpSciohd2chnFMdxsWz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ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id h3-20020a056402280300b00561410128e0si814482ede.51.2024.02.09.08.56.46; Fri, 09 Feb 2024 08:56:47 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=bijZpXZS; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 09BEE68D081; Fri, 9 Feb 2024 18:56:44 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0A80B68CCB5 for ; Fri, 9 Feb 2024 18:56:37 +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=bijZpXZS; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id E55F34486 for ; Fri, 9 Feb 2024 17:56:35 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id QNGTHd3HDSR0 for ; Fri, 9 Feb 2024 17:56:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1707497794; bh=dN8y7fpwJquAnq2J7JzXKAsj4j0uLhSfB/4xcxoLB2k=; h=From:To:Subject:Date:From; b=bijZpXZSn/iYNig0H/rnAHX8UTyBRckoIkOoZOEaloDBETcILvseCtTuRvTwpf0Wv tSQJ0rCLLEoNFmLQj/KajTJmcZL52UnBJ/QJGobUxOlg5l2tloTEvCN0oWkNAOcVLP 12XFJi7F5dv22ZfwKwg/BuFMcnL++1nEVTC1h2bb0CmxhPQ8DSkRhrlTW4gsPZ+V7L khzicpbPBODeSS0Wz6Gr946Gg2odV2v2Otc96zMXlEfnHykEBbizFDTH0j/7xSRLg/ nzLqibLFe/zryqiIPJMyksQ1K/tNYWH9nNmuDJJEZUY2peUIdvrP5zFjMTpAhY9mAg wAnQgPBk6sFNg== 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 C3D4CEEC for ; Fri, 9 Feb 2024 17:56:34 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 70A763A0435 for ; Fri, 9 Feb 2024 17:56:27 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Fri, 9 Feb 2024 17:54:03 +0100 Message-ID: <20240209165459.26190-1-anton@khirnov.net> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v3] Require compilers to support C11. 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: Rpa7L8/1wz9h 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(-) diff --git a/Changelog b/Changelog index c5fb21d198..610ee61dd6 100644 --- a/Changelog +++ b/Changelog @@ -24,6 +24,9 @@ version : - ffmpeg CLI options may now be used as -/opt , which is equivalent to -opt > - 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